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

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

Asked by
zGavinz 11
3 years ago
Edited 3 years ago
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.

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 Spjureeedd 385 — 3y
0
More specifically, Character is a reference to an Instance, but it isn't an Instance itself. DeceptiveCaster 3761 — 3y
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. kepiblop 124 — 3y

1 answer

Log in to vote
0
Answered by
kepiblop 124
3 years ago

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
Ad

Answer this question