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

I cant stop my cutscene in a local script?

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)

1 comment

0

Maybe is it because the repeat wait(). Turn it to scriptable once the character loads in maybe instead of a repeat.

1 answer

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!

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