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 6 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 — 6y

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
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.

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

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
Log in to vote
0
Answered by
sad_eyez 162
6 years ago

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

Answer this question