Tween can start but not stop?

Inside of a completed function for a tween, I have this if statement. It tells me that the tween is physically being cancelled or paused, but for some reason the tween continues.

if playbackState == Enum.PlaybackState.Cancelled or playbackState == Enum.PlaybackState.Paused then
	print("error1")
end

This system is part of a camera “cutscene” type thing, and the player’s camera (although resuming periodically to the player’s body) for some reason continues the tween that I had paused. I’ve tested this with other similar things, and it seems like I can’t pause a tween without it completing its cycle for some reason… I can provide small bits of snippets but I’d prefer if I didn’t have to share all of the code.

3 Likes

Well I’m assuming you’re using the completed event, these Enums describe whether the tween has been cancelled (before completion) or paused (also before completion). The completed event will change the playback state to Enum.PlaybackState.Completed

See here: PlaybackState | Documentation - Roblox Creator Hub

1 Like

Thanks for the reply. Although, the error message seems to only play when the tween is cancelled or paused and not when it is completed. And yes I am using the completed event, which a playbackState parameter.

Also an update. Apparently the error message does not pop up when the playback state is paused, even though I had paused the tween as well after cancelling it (cancelling it just resets it)
image

Well if it’s in the event, it won’t print because the tween.Completed event won’t have fired since the tween would’ve been paused. So that print statement won’t run either.

If you wanna detect when these states are changed at all use a Tween:GetPropertyChangedSignal event.

local function onPlaybackChanged()
	print("Tween status has changed to:", tween.PlaybackState)
end

local playbackChanged = tween:GetPropertyChangedSignal("PlaybackState")
playbackChanged:Connect(onPlaybackChanged)
1 Like

image
None of these produce any output.

image

1 → Right after the tween starts playing, I printed the playback state.
2 → When the tween is still playing, I clicked a button which triggered an if condition which checked to see if this tween was playing, and it says it’s back at begin? even tho its definitely playing
3 → after 1 second, the tween is definitely still playing and I wrote another print(tween.playbackstate). It’s definitely still playing on the client’s screen and not sure why it says this.

Please help if possible

Another thing I find odd:
image

This is the same script… I made a while true do statement to print the status of the playback state… the one “playing” response is from right after the tween begins but then the playback state goes right back to begin?

Then I think it’s due to the actual tween itself rather than the states, could you show the code of how you’re making and playing the tween?

one.Completed:Connect(function()
	currentCamera.CFrame = PlayScreenAnim.TwoStart.CFrame
	local two = ts:Create(currentCamera, tweeninfo, {CFrame = PlayScreenAnim.TwoEnd.CFrame}) 
	two:Play()
	print(two.PlaybackState)
	two.Completed:Connect(function()
		currentCamera.CFrame = PlayScreenAnim.OneStart.CFrame
	end)
end)

I’m aware that having the two.completed function within the one.completed function is generally bad practice. But in this case, it works well enough for me and when I try separating them I get stuttery camera movement that jumps back to the player occasionally.

In addition to this while loop.

while true do
print(two.PlaybackState)
if currentCamera.CFrame == PlayScreenAnim.OneStart.CFrame then
if script.Parent.Parent.Parent.Visible == false then
else
one:Play()
wait(1)
end
end
wait()
end

Not only bad practice, but would lead to a memory leak.

What I meant was, the code creating the “one” tween.

Ohhhh interesting. How can I solve this? because when I separate the two, the tween cuts back to the player’s camera before looping again.

Well i’d need to know how you create the “one” tween aswell. Because right now it’s just a best guess.

1 Like


local tweeninfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local one = ts:Create(currentCamera, tweeninfo, {CFrame = PlayScreenAnim:WaitForChild("OneEnd").CFrame})
local two = ts:Create(currentCamera, tweeninfo, {CFrame = PlayScreenAnim:WaitForChild("TwoEnd").CFrame})

Sorry to bother. Do you have a solution for this?