Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i use :Clone() on GetChildren?

Hello, i am making minigames. I want to make this --> If there is Tools folder in map. The tools will in Player.Backpack i want to this but its not working. Sorry my english and scripting isnt really good.

		if workspace:FindFirstChild(map.Name).Tools then
			local tools = workspace:FindFirstChild(map.Name).Tools:GetChildren()
			tools:Clone().Parent = Player.Starterpack
		else
			print('No gears')
		end

1 answer

✓ Accepted answer

Clone is only a function of instances. GetChildren returns a normal array. You have to loop through the array to actually use the instances.

btw FindFirstChild is for verification (returns either a child or nil), so don't try to immediately use its result. I'll assume map.Name is valid.

if workspace[map.Name]:FindFirstChild("Tools") then
    for _,tool in ipairs(workspace[map.Name].Tools:GetChildren()) do
        tool:Clone().Parent = Player.Starterpack
    end
else
    print('No gears')
end

1 comment

0

Thanks bro!

This discussion is preserved as it was. New answers, comments, and votes are closed.