Can't Stop Tween

I need to stop one of my tweens. When I first run this script it creates a tween, let’s call it “Bacon”. But when I run this script a second time it creates another tween, let’s call it “Eggs”. “Bacon” is still running but I’m not able to stop it because I already created “Eggs” and the script registers upTween as “Eggs”. So if I use upTween:Pause() it’s going to stop “Eggs”. But I need “Bacon” to be stopped. Is there a way I can do that? (I can’t create a second upTween because I need specific conditions but if you can prove me wrong please do so.)

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local upTween = TweenService:Create(charAttachment, tweenInfo, {
	Position = Vector3.new(charAttachment.Position.X, 1.5, charAttachment.Position.Z),
	Orientation = Vector3.new(charAttachment.Orientation.X, charAttachment.Orientation.Y, -5)
})

Can’t you just do :Cancel before you create your new tween?

1 Like

:Cancel() should cancel the tween.

You can read about TweenService here. TweenService | Documentation - Roblox Creator Hub

1 Like

And how exactly would I do that? If I put :Cancel before upTween then obviously upTween will register as nil because it haven’t been defined yet. I think I’ve been misunderstood.

--stuff
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1)
local upTween = TweenService:Create(charAttachment, tweenInfo, {
	Position = Vector3.new(charAttachment.Position.X, 1.5, charAttachment.Position.Z),
	Orientation = Vector3.new(charAttachment.Orientation.X, charAttachment.Orientation.Y, -5)
})
--stuff

The tween isn’t duplicated inside the script. The script itself runs twice. And I want to stop the first tween that has been created, not the second one.

I’m sorry but why are you running the script twice instead of just using a loop or playing this tween in one main script?

I have found the solution to this problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.