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

Why is my tween not pausing inside a loop?

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?

1 comment

0

I'm not completely sure, but maybe override has to be enabled to pause it.

1 answer

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!

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