Ported Functions: Difference between revisions
(started work for helpful article) |
(Improvements) |
||
Line 2: | Line 2: | ||
Modern versions of ROBLOX include many new features and functions which provide an easier experience for creators to make their own game. Because of this, older ROBLOX clients have far less features and therefore functions to offer. Fortunately, due to these limitations, ROBLOXians have — in the past, and in the now — made their own functions to serve the same purpose as their counterparts in the present. | Modern versions of ROBLOX include many new features and functions which provide an easier experience for creators to make their own game. Because of this, older ROBLOX clients have far less features and therefore functions to offer. Fortunately, due to these limitations, ROBLOXians have — in the past, and in the now — made their own functions to serve the same purpose as their counterparts in the present. | ||
== WaitForChild == | |||
This function is a replacement for the function that's well known to most — if not all — scripters of ROBLOX. It keeps waiting until it finds a child with a specific name inside a specific parent. This kind of function can be found in old Animate scripts found inside a player's character! | |||
<syntaxhighlight lang="lua"> | |||
local function waitForChild(parent, name) | |||
while not parent:FindFirstChild(name, false) do | |||
wait(0.03) | |||
end | |||
return parent:FindFirstChild(name, false) | |||
return | |||
end | end | ||
</syntaxhighlight> | |||
== GetDescendants == | |||
This function is also considered a replacement to a very important function. It returns a table which contains all objects found within a requested object. | |||
<syntaxhighlight lang="lua"> | |||
local function getDescendants(instance) | |||
local descendants = {} | |||
for i, v in ipairs(instance:GetChildren()) do | |||
table.insert(descendants, v) | |||
for j, w in ipairs(getDescendants(v)) do | |||
for i, v in | table.insert(descendants, w) | ||
table.insert(descendants, v) | |||
for j, w in | |||
table.insert(descendants, w) | |||
end | end | ||
end | end | ||
return descendants -- returns all children found | return descendants -- returns all children found | ||
end | end | ||
</syntaxhighlight> |
Revision as of 18:58, 21 July 2023
Work In Progress This is currently being worked on! Check back later for more information... hopefully. |
Modern versions of ROBLOX include many new features and functions which provide an easier experience for creators to make their own game. Because of this, older ROBLOX clients have far less features and therefore functions to offer. Fortunately, due to these limitations, ROBLOXians have — in the past, and in the now — made their own functions to serve the same purpose as their counterparts in the present.
WaitForChild
This function is a replacement for the function that's well known to most — if not all — scripters of ROBLOX. It keeps waiting until it finds a child with a specific name inside a specific parent. This kind of function can be found in old Animate scripts found inside a player's character!
local function waitForChild(parent, name)
while not parent:FindFirstChild(name, false) do
wait(0.03)
end
return parent:FindFirstChild(name, false)
end
GetDescendants
This function is also considered a replacement to a very important function. It returns a table which contains all objects found within a requested object.
local function getDescendants(instance)
local descendants = {}
for i, v in ipairs(instance:GetChildren()) do
table.insert(descendants, v)
for j, w in ipairs(getDescendants(v)) do
table.insert(descendants, w)
end
end
return descendants -- returns all children found
end