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

Finding a child with a name that has a space?

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

3 comments

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")

0

You need to pass the string to FindFirstChild such as player.Name

0

Oh okay thanks screwdeath that worked

1 answer

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")

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