Tween speed issue

So what the bottom code does so far is, it tweens both the rotation and position of a primary part that I have hooked up to a model.

It works fine, although I’ve noticed a huge issue, it seems every single time the rotation tween plays, it gets faster and faster, it starts off slow and after each loop, it just goes really fast until at one point causes lag and bugs out.

I feel like the issue lies inside
local rotation = {
Rotation = primary.Rotation + Vector3.new(0,90,0)
}
but I’m not sure what I should use instead of adding a new Vector3 each time.
Keep in mind I’m also using a primary part so CFrames would be an option I just have no idea how I would implement it

local originalrotation = primary.Rotation

local rotation = {
	Rotation = primary.Rotation + Vector3.new(0,90,0)
}

local info = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	100,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)


local position = {
	CFrame = primary.CFrame + Vector3.new(0,0,20)
}


local info2 = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

local partTween = TweenService:Create(primary, info, rotation)
local partTween2 = TweenService:Create(primary, info2, position)

partTween:Play()
partTween2:Play()

Maybe you can destroy the tween value, then recreate it. Like after it plays you can do partTween:Destroy, and then maybe add a script to re create it? Sorry I’m not too advanced with tween.

maybe try doing this :

Place the math.rad by the axis you want to rotate it around

this example rotates it around the X axis

CFrame = primary.CFrame * CFrame.Angles(math.rad(X), Y, Z)

I tried implementing that and it does not rotate anymore

Can you see any errors in the output?

No there are no errors, I guess the reasoning for this is because playing two tweens can override each other, and since i’m changing the Cframes rotation and position, it seems to only be changing the primary parts position and ignoring the rotation

I played the tween in a brand new file and nothing seemed to go wrong, or at least, nothing was getting faster. If possible could you send me your whole script?

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local primary = game.Workspace.traps.tallspikes.tallspike.primary

local rotation = {
	Rotation = primary.Rotation + Vector3.new(0,90,0)
}


local info = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	100,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)


local position = {
	CFrame = primary.CFrame + Vector3.new(0,0,20)
}

local position2 = {
	CFrame = primary.CFrame + Vector3.new(0,0,20)
}

local info2 = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

local partTween = TweenService:Create(primary, info, rotation)
local partTween2 = TweenService:Create(primary, info2, position)


partTween:Play()
partTween2:Play()

What I’m getting is this:


Is this how it’s supposed to look or is there more info I’m missing like orientation?

thats correct but yes you’re missing the rotation, it should spin while it moves back and fourth

1 Like

Ok try this

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local primary = game.Workspace.traps.tallspikes.tallspike.primary

local rotation = {
	Rotation = primary.Rotation + Vector3.new(0,360,0)
}

local info = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	100,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)


local position = {
	CFrame = primary.CFrame + Vector3.new(0,0,20)
}

local info2 = TweenInfo.new(
	--time, easingstyle repeatcount(negative number loops indefinitely), reverses(true/false), delay
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	-1,
	true
)

local position2 = {
	CFrame = primary.CFrame + Vector3.new(0,0,20)
}

local partTween = TweenService:Create(primary, info, rotation)
local partTween2 = TweenService:Create(primary, info2, position)


partTween:Play() --orientation
partTween2:Play() --position

I didn’t change much, but do you still get the issue of it going faster and faster? Because if so, I’m pretty sure it’s not anything with the Tween.

Yeah unfortunately it still speeds up, maybe it’s just some flaw on my end, although it works the same. Thank you anyway, I’ll just go with this for now maybe in the future I can figure something out :smiley:

1 Like

Sounds good, hopefully you can fix it eventually.

1 Like