Tween Service glitches

Hello!

My tween service glitches and snaps to an orientation when spinning.

Script:

local TweenService = game:GetService("TweenService")
local function createTween(part)
	local tweenInfo = TweenInfo.new(
		3, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching its goal)
		0 -- DelayTime
	)

	local goal = {}
	goal.Orientation = Vector3.new(0, 360, 0) -- Spin 360 degrees

	local tween = TweenService:Create(part, tweenInfo, goal)
	tween:Play()
end

local CorrodeLure = script.Parent["Corroded Lure"]
createTween(CorrodeLure)

local BegginnersLure = script.Parent["Begginner's Lure"]
createTween(BegginnersLure)

local FrailLure = script.Parent["Frail Lure"]
createTween(FrailLure)

local PaperLure = script.Parent["Paper Lure"]
createTween(PaperLure)

local CopperLure = script.Parent["Copper Lure"]
createTween(CopperLure)

local SwiftLure = script.Parent["Swift Lure"]
createTween(SwiftLure)

local BlessedLure = script.Parent["Blessed Lure"]
createTween(BlessedLure)

1 Like

use CFrame instead of orientation

edit: CFrame.fromOrientation(math.rad(degree), math.rad(degree), math.rad(degree))

2 Likes

I got this error
10:34:06.342 Unable to cast to Dictionary - Server - Script:15

local TweenService = game:GetService("TweenService")
local function createTween(part)
	local tweenInfo = TweenInfo.new(
		3, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching its goal)
		0 -- DelayTime
	)

	local goal = {}
	goal = CFrame.fromOrientation(math.rad(0), math.rad(360), math.rad(0)) -- Spin 360 degrees

	local tween = TweenService:Create(part, tweenInfo, goal)
	tween:Play()
end

local CorrodeLure = script.Parent["Corroded Lure"]
createTween(CorrodeLure)

local BegginnersLure = script.Parent["Begginner's Lure"]
createTween(BegginnersLure)

local FrailLure = script.Parent["Frail Lure"]
createTween(FrailLure)

local PaperLure = script.Parent["Paper Lure"]
createTween(PaperLure)

local CopperLure = script.Parent["Copper Lure"]
createTween(CopperLure)

local SwiftLure = script.Parent["Swift Lure"]
createTween(SwiftLure)

local BlessedLure = script.Parent["Blessed Lure"]
createTween(BlessedLure)

2 Likes

it should be goal.CFrame = the cframe

and cframe should be part.CFrame * the rotation cframe u have

2 Likes

Not quite sure what you mean can you put that in code form?

2 Likes

I wouldn’t recommend doing it like this. Honestly just half the amount of time that it takes to tween and then make it only go 180 degrees. This is a simpler way and I’ve had better success with it. Also, the reason that this isn’t working for you is because the object doesn’t currently have a 0 degree rotation on the y axis.

Whatever you decide to go with should be fine, but yeah basically just do Vector3.new(0, Object.Orientation.Y + 360, 0) (or 180) or do the more universal/accurate solution: Object.Orientation + Vector3.new(0, 180, 0).

Like I said, doesn’t really matter because scripting has multiple solutions but this is what I think will work.

1 Like
local goal = {}
goal.CFrame = part.CFrame * CFrame.Angles(0,math.rad(360), 0)
1 Like

The tween doesn’t play.

local TweenService = game:GetService("TweenService")
local function createTween(part)
	local tweenInfo = TweenInfo.new(
		3, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching its goal)
		0 -- DelayTime
	)

	local goal = {}
	goal.CFrame = part.CFrame * CFrame.Angles(0,math.rad(360), 0)-- Spin 360 degrees

	local tween = TweenService:Create(part, tweenInfo, goal)
	tween:Play()
end

local CorrodeLure = script.Parent["Corroded Lure"]
createTween(CorrodeLure)

local BegginnersLure = script.Parent["Begginner's Lure"]
createTween(BegginnersLure)

local FrailLure = script.Parent["Frail Lure"]
createTween(FrailLure)

local PaperLure = script.Parent["Paper Lure"]
createTween(PaperLure)

local CopperLure = script.Parent["Copper Lure"]
createTween(CopperLure)

local SwiftLure = script.Parent["Swift Lure"]
createTween(SwiftLure)

local BlessedLure = script.Parent["Blessed Lure"]
createTween(BlessedLure)
1 Like

It doesn’t look like it’s playing solely because 360 degrees = 0 degrees. With this in mind, it will be playing, just won’t look like it’s doing anything. You should use my solution of adding 180 degrees each iteration (and like I said, you’re going to have to half the amount of time in the tween too).

local TweenService = game:GetService("TweenService")
local function createTween(part)
	local tweenInfo = TweenInfo.new(
		1.5, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching its goal)
		0 -- DelayTime
	)

	local goal = {}
	goal.CFrame = part.CFrame * CFrame.Angles(0, math.pi, 0)-- Spin 360 degrees

	local tween = TweenService:Create(part, tweenInfo, goal)
	tween:Play()
end

local CorrodeLure = script.Parent["Corroded Lure"]
createTween(CorrodeLure)

local BegginnersLure = script.Parent["Begginner's Lure"]
createTween(BegginnersLure)

local FrailLure = script.Parent["Frail Lure"]
createTween(FrailLure)

local PaperLure = script.Parent["Paper Lure"]
createTween(PaperLure)

local CopperLure = script.Parent["Copper Lure"]
createTween(CopperLure)

local SwiftLure = script.Parent["Swift Lure"]
createTween(SwiftLure)

local BlessedLure = script.Parent["Blessed Lure"]
createTween(BlessedLure)
2 Likes

Thanks! now the parts spin without any glitches!

1 Like

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