When I press the skip button I want the tweening to stop and the camera to be set back to custom. So I want everything to be normal again but unfortunately this is not the case because when I click the skip button the camera is still tweening and carrying on. my script just completely ignores and pretends like the skip button wasnt even clicked and that there is no code to be executed when its clicked and just keeps moving the cameras cframe in my while loop anyway
local TweenService = game:GetService("TweenService")
local CutsceneFolder = game.Workspace:WaitForChild("CutsceneFolder")
local camera = game.Workspace.Camera
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local TextDisplayGui = PlayerGui:WaitForChild("TextDisplay")
local PlayButton = TextDisplayGui:WaitForChild("Play")
local SkipButton = TextDisplayGui:WaitForChild("Skip")
local currentTween
function tween(part1, part2, tweenInfo)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
currentTween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
currentTween:Play()
currentTween.Completed:Wait()
camera.CameraType = Enum.CameraType.Custom
end
PlayButton.MouseButton1Click:Connect(function()
camera.CameraType = Enum.CameraType.Custom
if currentTween then
currentTween:Cancel()
currentTween = nil
end
end)
SkipButton.MouseButton1Click:Connect(function()
camera.CameraType = Enum.CameraType.Custom
if currentTween then
currentTween:Cancel()
currentTween = nil
end
end)
local cutsceneTime = 10 -- How long the cutscene lasts
local tweenInfo = TweenInfo.new(
cutsceneTime,
Enum.EasingStyle.Quad, -- How it will animate
Enum.EasingDirection.Out,
0,
false,
0
)
while CutsceneFolder do
tween(CutsceneFolder["1"], CutsceneFolder["2"], tweenInfo)
tween(CutsceneFolder["3"], CutsceneFolder["4"], tweenInfo)
tween(CutsceneFolder["5"], CutsceneFolder["6"], tweenInfo)
end