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

How to Repeat Script after Died?

After I died my zoom was gone I keep doing it again over and over (sorry im bad at english.)

game.Players.LocalPlayer.CameraMaxZoomDistance = 1000

2 answers

Simply put a Script into ServerScriptService that tracks if the Player died. Then just fire the client with a RemoteEvent and put

game.Players.LocalPlayer.CameraMaxZoomDistance = 1000

into the LocalScript.

Just like that:

Script, located in ServerScriptService:

local Remoteevnt = --Location of RemoteEvent, would suggest ReplicatedStorage

game.Players.PlayerAdded:Connect(function(plr)

   plr.CharacterAdded:Connect(function(char)

      char.Humanoid.Died:Connect(function()

              Remoteevnt:FireClient(plr)
        end)
   end)
end)

LocalScript, located in StarterPlayerScripts:

local Remoteevnt = --Location of RemoteEvent

Remoteevnt.OnClientEvent:Connect(function()
     wait(game.Players.LocalPlayer.RespawnTime + 1)
     game.Players.LocalPlayer.CameraMaxZoomDistance = 1000
end)

If you get an error, feel free to write in in the comments, so I can look what the problem is.

If you put the script into StarterCharacterScripts it will run every time your character respawns, to optimise it a bit better with this method though I would recommend added a line so the script looks like this

game.Players.LocalPlayer.CameraMaxZoomDistance = 1000
script:Destroy()

Hopes this Helps!

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