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

How can you move all the children if they are tools from a certain spot?

How would I make it so it does this.

game.ServerStorage.AllTheToolsOnly.Parent = game.Lighting

I don't know what to do e.e

1 comment

1

You do not store tools in Lighting or replicated storage. The server should only give a tool to the player when you know they should have it.

3 answers

✓ Accepted answer
local serverstorage = game.ServerStorage
local lighting = game.Lighting

for i,v in pairs(serverstorage:GetChildren()) do
	if v:IsA("Tool") then
		v.Parent = lighting
	end
end

This script gets all the children of ServerStorage and checks if it is a tool. If it is then it will put it in the Lighting.

Use :IsA(...) to check if something's a subclass of something else.

for i, v in pairs(something:getChildren())
    if v:IsA("Tool") then
        v.parent = game:GetService("Lighting")
    end
end

You would use a for loop


local tools = game:GetService("ServerStorage")["TheTools"] -- Assuming their in a folder

for i,v in pairs(tools:GetChildren()) do
	v.Parent = game:GetService("Lighting")
end


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