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

How Do I Insert PointLight Into The Player Lua Form?

Here's the script:

game.Players.PlayerAdded:connect(function(player)
L = Instance.new("PointLight", Players.LocalPlayer.Torso)
end)

for _, player in pairs(game.Players:GetPlayers()) do
PlayerAdded() --- Where I'm Stuck At. Halp D:
end                                                

I am basically trying to get the PointLight inside the player so they can be bright. I have checked everything I did:

  • It is in a local script
  • It is in a StarterPack

The only part I am stuck on Line 6. Can anyone help me please?

2 answers

I'm not sure if this is exactly what you want, but this will insert a light in every character's torso that spawns.


function Spawned(char)
	L = Instance.new("PointLight", char.Torso)
end

function PlayerAdded(player)
	player.CharacterAdded:connect(Spawned)
end
game.Players.PlayerAdded:connect(PlayerAdded)

2 comments

0

I don't know if it worked but the output only said in red letters: 16:15:39.338 - Plugin_142731176._Char:15: attempt to index local 'myPlayer' (a nil value). What does that mean?

0

That isn't an error associated with this script.... That error is from some plugin you have that is not working correctly and has nothing to do with this.

Lol'd at, easy

game.Players:PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local point = Instance.new("PointLight", char.Torso)
point.Range = 40
point.Brightness = 50
end)
end)

1 comment

0

Ikr

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