lune/tests/roblox/instance/methods/FindFirstAncestor.luau
2023-03-25 18:04:19 +01:00

16 lines
516 B
Lua

local roblox = require("@lune/roblox") :: any
local Instance = roblox.Instance
local root = Instance.new("Folder")
local child = Instance.new("Model")
local nested = Instance.new("Tool")
local descendant = Instance.new("Part")
descendant.Parent = nested
nested.Parent = child
child.Parent = root
assert(descendant:FindFirstAncestor("Part") == nil)
assert(descendant:FindFirstAncestor("Tool") == nested)
assert(descendant:FindFirstAncestor("Model") == child)
assert(descendant:FindFirstAncestor("Folder") == root)