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

How to get all childrens of Lighting?

Asked by 6 years ago
Edited 6 years ago

So. I have a localscript inside a tool that hides the player when he clicks and and unhides him when he unequips it. To hide the hats, I move them all into Lighting however I don't know any quick method to get them back.

local tool = script.Parent
local othertool = game.Lighting
local function onActivate()
    local char = game.Players.LocalPlayer.Character
    for _, obj in pairs(char:GetChildren()) do
            if obj:IsA("Accoutrement") then
obj.Parent = othertool
char.Head.face.Parent = tool
tool.Handle.Transparency = 1
    char.Head.Transparency = 1
    char['Right Arm'].Transparency = 1
    char['Left Arm'].Transparency = 1
    char.Torso.Transparency = 1
    char['Right Leg'].Transparency = 1
    char['Left Leg'].Transparency = 1
    end
    end
end
tool.Activated:Connect(onActivate)
local function onUnequip()
    local char = game.Players.LocalPlayer.Character
tool.face.Parent = char.Head
tool.Handle.Transparency = 0
    char.Head.Transparency = 0
    char['Right Arm'].Transparency = 0
    char['Left Arm'].Transparency = 0
    char.Torso.Transparency = 0
    char['Right Leg'].Transparency = 0
    char['Left Leg'].Transparency = 0
end
tool.Unequipped:Connect(onUnequip)

1 answer

Log in to vote
0
Answered by 6 years ago

To get all of the children of something, you can just use :GetChildren(). Example:

game.Lighting:GetChildren()
0
Thanks. I'll try eloiishot 47 — 6y
Ad

Answer this question