How to make camera tween not run on player death

I’ve made a camera tween using AlvinBlox’s tutorial, but the problem is, the tween runs when the player resets.

How would I make it so that it does not reset when the player dies? I might want it to run multiple times, but not when the player resets.

Code
local TweenService = game:GetService("TweenService")
local cams = game.Workspace.Cameras
local done = false

local camera = game.Workspace.Camera

local sceneTime = 20

local tweeninfo = TweenInfo.new(
	sceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

function tween(camera1, camera2)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = camera1.CFrame
	
	local tween = TweenService:Create(camera, tweeninfo, {CFrame = camera2.CFrame})
	tween:Play()
	
	wait(sceneTime)
	
	camera.CameraType = Enum.CameraType.Custom
end

wait(2)

tween(cams.Camera1, cams.Camera2)
tween(cams.Camera3, cams.Camera4)
tween(cams.Camera5, cams.Camera6)
tween(cams.Camera7, cams.Camera8)
tween(cams.Camera9, cams.Camera10)

Thanks!

Where is this script located? Probably is somewhere where the script is remade again

LocalScript inside StarterGUI.

There’s why then, the script is going to be remade anything you reset since anything in StarterGui will be replicated to your PlayerGui, except SCreenGuis with ResetOnSpawn disabled.

There seems to be nothing that could be messed up by moving the localscript, so put it somewhere like StarterPlayerScripts?

1 Like