Hello! So I’m trying to change the Parent of a random part that is inside a specific folder.
But the script doesn’t work. I wonder why…
Are there any errors that is given in the output?
Yeah.
It apparently returns nil
.
using FindFirstChild
will either return the Instance if it exists, nil if not, if it returns nil, since you can’t clone nil you might road to an error
Second, you maybe tried to write items[math.random(1, #items:GetChildren())]
instead of math.random(1, #items:GetChildren())
, if it was intended, try using tostring() because FindFirstChild’s parameter should be a string
I think this is what you meant:
local ItemPicked = folder:FindFirstChild(items[math.random(1, #Items:GetChildren())])
-- Gets a random value inside items folder
if ItemPicked then -- If ItemPicked exists
ItemPicked.Parent = folder.One
end
2 Likes