Cutscene repeating?

Hi, there. I have already achieved what I wanted to, but I had to note something.

The cutscene plays fine. After it’s over, it’s supposed to not play anymore. But when I reset, it plays it again, even tho the script should’ve destroyed itself? I don’t understand how this is happening and it’s really confusing. And suprisingly not getting any errors.

I’ve tried changing some of the code, but most of that just breaks the cutscene.

Here’s the code:

wait(5)

local CameraParts = game.Workspace.CameraParts
local Camera = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")

function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart})
	Cutscene:Play()
	wait(Duration)
end


function Cutscene()
	MoveCamera(CameraParts.Part1.CFrame, CameraParts.Part2.CFrame, 3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
	wait(1)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
	script:Destroy() -- After the cutscene concludes, the script is supposed to destroy by itself.
end

Cutscene()

Really would love some advice and help, thanks.

If the LocalScript was placed into the StarterCharacterScripts container, the StarterGui, or in a ScreenGui with the ResetOnSpawn property set to true, a brand new copy of the LocalScript will be given to the player every time they respawn and the code inside of it will run.

1 Like

Thank you so much!! Solved my issue.

1 Like

if u cant put the local script for cutscene there then where do you place it? because i want to know if im making cutscene in the future

The LocalScript can still be placed into those different containers; you’ll just have to ensure that the code which is responsible for making the cutscene work is not automatically played.

Determining if a player has already watched a cutscene could be accomplished in various ways. One example includes storing a value in a ModuleScript that will indicate if a player has already been through a cutscene; this value can be changed during a function where the cutscene is activated.


This enables you to incorporate a conditional statement before activating the function which will check what the value is set to before continuing.

Basic Example:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local moduleScript = require(ReplicatedStorage.ModuleScript)

local function activateCutscene()
    moduleScript.hasPlayedCutscene = true
    -- Code related to the cutscene goes here
end

if moduleScript.hasPlayedCutscene == true then
    print("The player has already watched the cutscene!")
else
    activateCutscene()
end

Keep in mind that there are other ways this could be accomplished – this was just one of the more straight-forward and generic solutions that came to mind, as there isn’t much context for how many cutscenes there might be, which ones can be replayed and which cannot, & etc.