PointLight is being created in studio, but not in game?

I’m trying to create a PointLight object locally so that only the client see’s it. My script goes like this:

local Player = game:GetService("Players").LocalPlayer

function CreateLight()
	local Light = Instance.new("PointLight")
	Light.Brightness = 1
	Light.Shadows = true
	return Light
end

Player.CharacterAdded:Connect(function(Character)
	local Light = CreateLight()
	Light.Parent = Character:WaitForChild("Head")
end)

When I play test in studio, it works just fine; However when I get in game the PointLight object is created and put into the right spot, but it shows no light, it is enabled and in the correct spot but it doesn’t produce light.

Here are some details in my game that might be useful:

  • The camera stays 1600 studs away from the player, but I’m certain this isn’t directly causing it because I tried it with the camera at a regular distance.
  • The StarterCharacter has been changed, and the Head starts as transparent

Anyone have any ideas?

Are you doing this in the day environment? It may be impossible to see the light if the game’s time is the day, not night. Did you also enable PointLight via Property Enabled? Make sure that it’s enabled. Otherwise, you can’t see the lighting effect.

I also recommend increasing the brightness and range. Very low brightness and range of the lighting is hard to perceive.

No it’s dark, it is enabled, and I just tried changing the brightness value, it still is not showing light.

1 Like

I tried implementing the PointLight you made. I see how you barely see the light coming out of the head. I recommend increasing the range. You must increase the range for the light to light within the field. If we were to have it as 10, the lighting range would light up a radius of ten. If the lighting’s radius is one, it’s barely visible and hardily any light is coming out.

My game is set to the darkest it can possible be. Trust me, the light is perfectly visible when it is visible.

Maybe try adjusting its range to 2-5 and brightness a bit lower than 10.

it is possible that your character is created before the script runs. I’d suggest making a CharacterAddedFunction and set it up like this:

function characterAdded(Character)
	local Light = CreateLight()
	Light.Parent = Character:WaitForChild("Head")
end
Player.CharacterAdded:Connect(charcterAdded)
if player.Character then	-- This will also run the function on an existing character
	characterAdded(Player.Character)
end

This also can certainly be the problem. You are probably not rendering it from that far away, with different render settings between a live game vs studio.

-- ss in sss
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
         game.ReplicatedStorage.Event:Fire(char)
    end)
end)
-- ss in sss (separate script)
game.ReplicatedStorage.Event.Event:Connect(function(char)
    local Light = Instance.new("PointLight")
	Light.Brightness = 1
	Light.Shadows = true
    Light.Parent = char
end)

I think this should work, but let me know if there is any errors

Thank you very much! Yes, it was in fact that my character was loading before the script was. Thank you so much!

1 Like