Ported Functions

From Legacy Roblox Wiki
Revision as of 19:34, 21 July 2023 by Tobufi (talk | contribs) (started work for helpful article)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
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!

function WaitForChild(where, what) -- the "where" parameter is an object, and the "what" parameter is a string 
	while not where:FindFirstChild(what) do wait() end -- wait until finds the "what" string inside the "where" object
	return where:FindFirstChild(what) -- return the child
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.

function GetDescendants(instance) -- the "instance" parameter is an object
	local descendants = {}
	for i, v in pairs(instance:GetChildren()) do -- loop through children of parameter
		table.insert(descendants, v) -- insert child into table
		for j, w in pairs(GetDescendants(v)) do -- loops again by firing itself; creates a loop and returns itself until all children are found
			table.insert(descendants, w) -- insert child of child of ... into table
		end
	end
	return descendants -- returns all children found
end