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

Getting camera to completely reset after respawn?

Asked by 4 years ago

Here I made a script that creates a new camera that acts differently than the normal player camera. When you fall off the stage, this one is created, and watches the player from a distance. However, when you respawn and the camera is removed, the angle is wrong, and the player would have to manually adjust it to be normal again. How could I get the camera back to "normal" after the player respawns? With the camera behind their back, and at the default zoom distance, and all?

Here's the script:

local debounce = false
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

while true do
    if game.Players.LocalPlayer.Character.Torso.CFrame.Y < -17 and debounce == false then
        debounce = true
        local camera = Instance.new("Camera")
        camera.Name = "DeathCamera"
        camera.Parent = workspace
        camera.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame
        camera.CameraSubject = game.Players.LocalPlayer.Character.Torso
        camera.CameraType = Enum.CameraType.Watch
        workspace.CurrentCamera = camera
        repeat wait()
        until game.Players.LocalPlayer.Character.Humanoid.Health == 0
        wait(3)
        camera:Destroy()
    end
    wait(0.1)
end

Answer this question