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

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

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

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.

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