I have made a script that lets you see in first person when you play solo. However it doesn't work when you start a server or play the actual game. Can anybody help?

This is the code I used:

game.Players.PlayerAdded:connect(function(player)
while true do	
	player.CameraMode = Enum.CameraMode.LockFirstPerson
	wait()
	end
end)