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

Why is my tween not pausing inside a loop?

Asked by
Neatwyy 123
4 years ago
Edited 4 years ago

I have this script where it tweens the camera cframe and the blur, but I can't pause it in a loop.

local plr = game.Players.LocalPlayer
local TS = game:GetService("TweenService")
local camera1 = game.Workspace.Camera1
local camera2 = game.Workspace.Camera2
local camera = game.Workspace.CurrentCamera
local blur = game.Lighting.Blur
local started = false
local TI = TweenInfo.new(
    8,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local BlurTI = TweenInfo.new(
    1,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
repeat
    local blurtween = TS:Create(blur, BlurTI, {Size = 50})
    blurtween:Play()

    wait(2)

    local unblurtween = TS:Create(blur, BlurTI, {Size = 0})
    unblurtween:Play()

    local camtween = TS:Create(camera, TI, {CFrame = camera2.CFrame})
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = camera1.CFrame
    camtween:Play()
    wait(7.8)
function stop()
    blurtween:Pause()
    unblurtween:Pause()
    camtween:Pause()
end
until started == true


script.Parent.MouseButton1Click:Connect(function()
    started = true
        stop()
    camera.CameraType = Enum.CameraType.Custom
    script.Parent.Parent:Destroy()
end)

Does anyone know how to pause the tween?

0
I'm not completely sure, but maybe override has to be enabled to pause it. sngnn 274 — 4y

1 answer

Log in to vote
0
Answered by
Neatwyy 123
4 years ago

Whoops! I forgot it's in a while loop so the MouseButton1Click event won't run. :P I've put the MouseButton1Click event inside the loop and it worked!

Ad

Answer this question