Returns the first parent of the given class. This function searches upwards, which means it searches upwards from the direct parent of the object. If the matching parent node cannot be found, the function returns nil.


Variable name Type Default Description
ClassName string Class name of parent node to seek

Return Value

Type Description
RWObject Parent node object to seek. If no matching object, return nil.


Create a part. When this part is hit, delete the parent object of this part.

local temp1 = RWObject.Create("Part") -- create an instance temp1 of Part
temp1.Position = Vector3.New(0,1,2) -- set the coordinates of temp1
temp1.Anchored = true -- anchor temp1
local temp2 = RWObject.Create("Folder") -- create an instance temp2 of the folder
temp1.Parent = temp2 -- set the parent of temp1
local temp3 = temp1:GetAncestorByClassName("Folder") -- seek the parent of temp1, the class name of which is Folder
function s() -- define a method and name it s
   temp3:Destroy() -- delete the folder 
temp1.CollisionEnter:Connect(s) -- when temp1 is touched, call the s method to delete temp1.