For some reason my tween isn't working!

I have no clue why, but there are no errors, and I’ve been trying to figure this out for like 30 minutes, help appreciated!

local TweenService = game:GetService("TweenService")
local part = script.Parent
local tweenInfo = TweenInfo.new(
	2.5, -- Time
	Enum.EasingStyle.Linear, 
	Enum.EasingDirection.Out, 
	-1, 
	true, 
	0 
)
 
local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(23.481, 2.89, 31.457)})
 
tween:Play()
wait(0.5)
tween:Cancel()

I really cannot see why this isn’t working. Perhaps this is because of the script being in the wrong place. What type of script is this?

Try to squeeze the TweenInfo part into a line. It doesn’t work when it’s split into multiple lines (I don’t know why, but every time I squeeze it into a line, it works.)

I’m not sure but maybe try changing the -1 to 0. That number is how much times the tween will repeat play it self. If its -1 then the tween wont play…

The tween probably already got canceled before you got to get a look at it

Yes like @LukaDev_0 said your tween length is 2.5 seconds but you cancel in at 0.5 seconds so only 0.5 seconds of the tween will play and the other 2 seconds of the tween wont play.

Why not just first try without the wait and the tween:Cancel()? If this works, then you can set as argumeter for the wait function a >2.5 number or connect a completed event to the tween

Other people have already mentioned it, but I’m pretty sure it’s something to do with the tween:Cancel(). Try removing it and seeing what happens.

Also, why do you need it to be cancelled? Are you trying to move it to a certain position, or worried about timing?
→ If you’re trying to get it to a position mid-way through the tween, just change the time in your TweenInfo to 0.5 and place a part and move it to the position you want
→ If you’re just worried about the timing, then just change the time in your TweenInfo to 0.5
If it’s something else, please say!

A server script, child of a union

I tried that, the tween still doesn’t play

local TweenService = game:GetService(“TweenService”)
local part = script.Parent
local tweenInfo = TweenInfo.new(
2.5, – Time
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
true,
0
)

local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(23.481, 2.89, 31.457)})

tween:Play()
wait(2.5) --wait(0.5)
tween:Cancel()

This should work if if i’m correct.

My guess is 0.5 seconds is to short for the tween to even look like its starting…

I don’t appear to be having any issues running your tween. Is your part anchored?

Yeah it is, why? (30 chars is bad)

Try to unanchor your part, just try

1 Like

IIRC The developer hub says that -1 means infinite repeats…

Yep!

I just tested it, it does infinite repeats if the repeat count is -1.

normally if we set to -1 it’s will do a loop. i think that’s not the problem