if script.Parent.Parent.Character.Humanoid.Health == 0 then script.Parent.Parent.Parent.Parent.CameraMode = "Classic" end
I have the user in LockInFirstPerson, but I want it to where when he dies it changes Back to classic.
The main problem here is that you're trying to use a conditional to do something when something reaches a specific value. When Lua runs through those 3 lines, it will check to see if the health is 0. If the health isn't 0 when the interpreter is looking through the code, then it just skips over to whatever's next. Let's make it so that we change the camera mode as soon as the humanoid dies. To do that, we're going to connect a function to an event. This little script should look familiar to you.
part = script.Parent function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = 0 end end part.Touched:connect(onTouched)
And that kills people that touch the brick. Let's use the same principles to get what you're trying to accomplish.
function onDied() if script.Parent.Parent.ParentParent.CameraMode ~= "Classic" then script.Parent.Parent.Parent.Parent.CameraMode = "Classic" end end script.Parent.Parent.Character.Humanoid.Died:connect(onDied)
And there ya go. At the bottom, we account for the event that our poor character has died. We then connect that event to our pre-defined function, onDied.
I highly recommend learning a bit about LocalScripts and their capabilities. That way, you won't have to go script.Parent.Parent.Parent.Parent and all that jazz. Put this in a LocalScript and put it in StarterPlayerScripts in the StarterPlayer folder. Then change your player's camera mode to LockedFirstPerson, die, and see what happens.
player = game.Players.LocalPlayer function onDied() if player.CameraMode ~= "Classic" then player.CameraMode = "Classic" end end player.Character.Humanoid.Died:connect(onDied)
put inside workspace - script not local.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) char:WaitForChild("Humanoid") plr.CameraMode = 1 char.Humanoid.Died:wait() plr.CameraMode = 0 end) end)