Hi guys,
I need help with my script. Is there a method to find the first child that starts with XYZ?
For example, I have a part called XYZ93718361
.But I only now that it starts with XYZ
.
Something like
local x = game.workspace:FindFirstChildThatStartsWith("xyz") if x then print("Found a part that startswith XYZ") end
Thanks ;)
Doesn't exist, but this will work for you.
function FindFirstChildThatStartsWith(parent, name) for i,v in pairs(parent:children()) do if v.Name:sub(0, string.len(name)) == name then return v end end return nil end