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

How to get all childrens of Lighting?

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

✓ Accepted answer

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

game.Lighting:GetChildren()

1 comment

0

Thanks. I'll try

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