My script that gives the player a point light works... but only about half of the time. I have no idea why this is happening and it is very frustrating please help. It is a normal script attached to a part on top of spawn.
script.Parent.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid")then local light = Instance.new('PointLight') light.Parent = Hit.Parent.Head light.Brightness = 1 end end)
If it's on top of a spawn, I'm assuming you want it every single time they spawn. In that case, the CharacterAdded event would be your friend here. Your current code works well, and the only issue could be the lack of debounce in it. With the CharacterAdded event, no debounce is needed.
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char:WaitForChild('Head') -- wait until the head is there local light = Instance.new('PointLight') light.Brightness = 1 -- Better practice to set all properties before you parent it light.Parent = char.Head end) end)
Ask any questions!