#how to cancel a cutscene script with a button

1 messages · Page 1 of 1 (latest)

austere marten
#

my cutscene script wont cancel when i click my button, when i do, it just skips the first tween and moves on to the next so i have to keep pressing it until all tweens are done and it finally works

#
local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui

local CC = workspace.CurrentCamera

local Cameras = game.Workspace:WaitForChild("Cameras")
local MenuCams = Cameras:WaitForChild("MenuCams")
local Set1 = MenuCams.Set1
local S1C1 = Set1:WaitForChild("Cam1")
local S1C2 = Set1:WaitForChild("Cam2")

local Set2 = MenuCams.Set2
local S2C1 = Set2:WaitForChild("Cam1")
local S2C2 = Set2:WaitForChild("Cam2")

local Set3 = MenuCams.Set3
local S3C1 = Set3.Cam1
local S3C2 = Set3.Cam2

local RS = game:GetService("RunService")

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(8.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local TI2  = TweenInfo.new(.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local FadeFrame = plrgui:WaitForChild("Fade"):WaitForChild("Frame")

local Play = plrgui["Main Menu"]:WaitForChild("Frame"):WaitForChild("Play")

local Set1Tween = TS:Create(CC, TI, {CFrame = S1C2.CFrame})
local Set2Tween = TS:Create(CC, TI, {CFrame = S2C2.CFrame})
local Set3Tween = TS:Create(CC, TI, {CFrame = S3C2.CFrame})

local FadeTweenIn = TS:Create(FadeFrame, TI2, {BackgroundTransparency = 0})
local FadeTweenOut = TS:Create(FadeFrame, TI2, {BackgroundTransparency = 1})

local LobbyCams = true
#
local function LFade(NextSetCam)
    FadeTweenIn:Play()

    task.wait(.6)
    
    CC.CFrame = NextSetCam.CFrame

    task.wait(.6)

    FadeTweenOut:Play()
end

local function Fade(NextSetCam)
    FadeTweenIn:Play()

    FadeTweenIn.Completed:Wait()

    FadeTweenOut:Play()
end

Play.MouseButton1Click:Connect(function()
    LobbyCams = false
    Fade()
    Set1Tween:Cancel()
    Set2Tween:Cancel()
    Set3Tween:Cancel()    
end)

while LobbyCams do    
    CC.CameraType = Enum.CameraType.Scriptable
    CC.CFrame = S1C1.CFrame
    Set1Tween:Play()

    Set1Tween.Completed:Wait()
    
    LFade(S2C1)

    Set2Tween:Play()

    Set2Tween.Completed:Wait()
    
    LFade(S3C1)
    
    Set3Tween:Play()
    
    Set3Tween.Completed:Wait()
    LFade(S1C1)
end

#

im trying to make it so that it cancels the cutscene and it goes to a static cam part

austere marten
# austere marten

see here its making me have to click play 3 times until it can stop

frozen estuary
#

you need to reset the player camera to default

austere marten
#

i just need the cutscene to end for the static camera

frozen estuary
#

then set the player camera to the static camera

austere marten
#

like do i put it to default and then back to scriptable

frozen estuary
#

set CC.CFrame to the static camera

austere marten
#

ok

#

doesnt work

#

just does same thing

digital scroll
#

you haven't set up your code to be interruptable

#

calling tween:Cancel also raises .Completed, and because your function isn't interruptable, it raises the .Completed:Wait() and moves onto the next one

#

you'd have to re-work your loop so it can be interrupted

austere marten
#

its ok i already solved it

#

i just put a if on my variable bool and put it after the tween completed and it works