Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change camera type when health = 0, not working. Any help? [Solved]

I want to change the camera type for when the character dies, or when health is at 0, but return back to the normal camera view when respawned. I am trying to do that in this script, but for some reason, it's not working. Any thing I am doing wrong, or is it correct?

Player = script.Parent.Parent.Parent.Parent.Character
s = Player.Humanoid
while true do
if s.Health == 0 then
script.Parent.Visible = true
game.Workspace.Camera.CameraType = "Scriptable" --This doesn't work
wait(4)
end
if s.Health >= 0 then
script.Parent.Visible = false
game.Workspace.Camera.CameraType = "Custom" --This, also, doesn't work
end
wait()
end

1 answer

✓ Accepted answer

###Put this into a LocalScript in the StarterGui.

local plr = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
plr:WaitForCharacter()
local chr = plr.Character

cam.CameraType = Enum.CameraType.Custom

chr.Humanoid.Died:connect(function()
	cam.CameraType = Enum.CameraType.Scriptable
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.