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

Why is this very simple "put light into torso" localscript not working?

local light = Instance.new("PointLight") 
light.Parent = game.Players.LocalPlayer:WaitForChild("Character").Torso

Can somebody tell me why this does not work and how to fix this? There is no error. It is a very simple localscript and I can't think of any way how this doesn't work.

3 comments

0

As kepiblop said, you can't use WaitForChild on a Player Instance to get the Character. You can get the player's character from the property Character in the player

0

More specifically, Character is a reference to an Instance, but it isn't an Instance itself.

0

To be a bit more specific, If you made a instance inside that player named "Character" and used waitforchild or findfirstchild, It will return that instance.

1 answer

✓ Accepted answer

You cant waitforchild character, that just simply wont work. Instead, wait for the characteradded event to be fired, then put it inside Something like this.

local light = Instance.new("PointLight") 
game.Players.LocalPlayer.CharacterAdded:Wait()
light.Parent = game.Players.LocalPlayer.Character.Torso

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