I want the script to give the player the FirstPerson camera mode but when the player resets are dies it does not happen Here is the code (It is in a local script in the players gui)
Player = game.Players.LocalPlayer Clicked = false local player = game.Players.LocalPlayer Cam = workspace.CurrentCamera -- Currently not in use Player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() if Clicked then character:WaitForChild("Humanoid") print("The player has died") Player.CameraMode = Enum.CameraMode.LockFirstPerson print(Clicked) end end) end) game.workspace.Lobby.Log.PlayButton.SurfaceGui.ImageButton.MouseButton1Click:connect(function() Clicked = true Player.CameraMode = Enum.CameraMode.LockFirstPerson end)
You haven't added a function, therefore it cannot happen, this one should work:
function onDied() Player = game.Players.LocalPlayer Clicked = false local player = game.Players.LocalPlayer Cam = workspace.CurrentCamera -- Currently not in use Player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() if Clicked then character:WaitForChild("Humanoid") print("The player has died") Player.CameraMode = Enum.CameraMode.LockFirstPerson print(Clicked) end end) end) game.workspace.Lobby.Log.PlayButton.SurfaceGui.ImageButton.MouseButton1Click:connect(function() Clicked = true Player.CameraMode = Enum.CameraMode.LockFirstPerson end end) game.Players.LocalPlayer.Character.Humanoid.Died:connect(onDied)
Anything gone wrong? Anything gone right? Leave a comment and I'd be happy to help.