Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I cant stop my cutscene in a local script?

Asked by 2 years ago

Hi! I have this cutscene that moves from p1 to p2. However, i cant get the cutscene to stop when i press play? Any ideas? Thanks in advance!

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local char = player.Character
local p1 = workspace.Cutscene.cam1
local p2 = workspace.Cutscene.cam2
local playbutton = script.Parent.ClearFrame.PlayButton

repeat wait()
    camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = p1.CFrame

local function TweenCamera(pos)
    local TweenService = game:GetService("TweenService")
    local TweenInf = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
    local Tween = TweenService:Create(camera, TweenInf, {CFrame = pos})
    Tween:Play()
    end

wait(2)

TweenCamera(p2.CFrame)

playbutton.MouseButton1Click:Connect(function()
    camera.CameraType = Enum.CameraType.Custom
    script.Parent.ClearFrame.Visible = false
    coroutine.yield(TweenCamera)
end)

0
Maybe is it because the repeat wait(). Turn it to scriptable once the character loads in maybe instead of a repeat. AProgrammR 398 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Hi!! I figured it out! Sooooo, set

local Tween = TweenService:Create(camera, TweenInf, {CFrame = pos})

to

Tween = TweenService:Create(camera, TweenInf, {CFrame = pos})

and then at the top write

Tween = nil

finally in

playbutton.MouseButton1Click:Connect(function()
    camera.CameraType = Enum.CameraType.Custom
    script.Parent.ClearFrame.Visible = false
    coroutine.yield(TweenCamera)
end)

replace

coroutine.yield(TweenCamera)

with

Tween:Cancel()

Hope this helps people in the future!

Ad

Answer this question