Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
RAYAN1565 691 Moderation Voter
10 years ago

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

Log in to vote
2
Answered by 10 years ago

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)
Ad

Answer this question