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

How do I make the camera zoom out when the player dies, but then reset when they respawn?

Asked by
Lyphios 77
4 years ago

So in my game, I set the camera mode to lockfirstperson and set max and min zoom distances to 0.5 . However, I want the camera to zoom out when the player dies to about 20(..zoom units?). Here's the script I made.

local Player = game.Players.LocalPlayer
local character = Player.CharacterAdded:wait() ; Character = Player.Character
local hum = char:WaitForChild("Humanoid")

game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").Died:Connect(function()
            game.StarterPlayer.CameraMaxZoomDistance = 20
            game.StarterPlayer.CameraMode = Classic
    end)
end

However, nothing happens. It doesn't zoom out, it doesn't reset, nothing. Please fix my script and tell me what I did wrong.

1 answer

Log in to vote
0
Answered by 4 years ago

StarterPlayer

Changing the StarterPlayer, just like the StarterCharacter and the StarterGui (and all of the other Starter* classes) doesn't affect anything live. Instead you should modify the Player itself. You may as well also do this from a LocalScript and ask yourself why you need both a LocalPlayer and a PlayerAdded connection.

Ad

Answer this question