Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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
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. User#5423 17 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
1local serverstorage = game.ServerStorage
2local lighting = game.Lighting
3 
4for i,v in pairs(serverstorage:GetChildren()) do
5    if v:IsA("Tool") then
6        v.Parent = lighting
7    end
8end

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.

Ad
Log in to vote
0
Answered by
fredfishy 833 Moderation Voter
7 years ago

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

1for i, v in pairs(something:getChildren())
2    if v:IsA("Tool") then
3        v.parent = game:GetService("Lighting")
4    end
5end
Log in to vote
0
Answered by
sad_eyez 162
7 years ago

You would use a for loop

1local tools = game:GetService("ServerStorage")["TheTools"] -- Assuming their in a folder
2 
3for i,v in pairs(tools:GetChildren()) do
4    v.Parent = game:GetService("Lighting")
5end

Answer this question