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

Finding a child with a name that has a space?

Asked by 5 years ago

So I'm making a script that's supposed to change your skin colour, but to do that you need to find a value called 'Body Colours' in the player, how do I do that? I tried

local player = script.Parent.Parent
local Acplayer = game.Workspace:FindFirstChild(player)

Acplayer.Body Colour

but it cant find a child who's name has a space in it

0
When you want to reference a child with a space in its name, use square brackets. Ex: Acplayer["Body Colour"] An alternative is to use :FindFirstChild. Ex: Acplayer:FindFirstChild("Body Colour") ScrewDeath 153 — 5y
0
You need to pass the string to FindFirstChild such as player.Name User#5423 17 — 5y
0
Oh okay thanks screwdeath that worked UNBANhappyniceguy5 52 — 5y

1 answer

Log in to vote
0
Answered by
OBenjOne 190
5 years ago
Edited 5 years ago

I'm just going to put the answer @screwdeath posted as a comment in answers so people know this question has been answered:

When you want to reference a child with a space in its name, use square brackets. Ex: Acplayer["Body Colour"] An alternative is to use :FindFirstChild. Ex: Acplayer:FindFirstChild("Body Colour")

Ad

Answer this question