My tween snaps to a rotation once it turns 180 degrees.
Script:
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)
would be better if you just using RunService in stead of tweenService since the proforment of tweenservice is kinda bad
local function createRot(part)
local rotationSpeed = math.pi * 2 -- 360 degrees per second
local connection
connection = game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
-- Rotate a bit each frame based on delta
part.CFrame = part.CFrame * CFrame.Angles(0, rotationSpeed * deltaTime, 0)
end)
end
local lures = {
script.Parent["Corroded Lure"],
script.Parent["Begginner's Lure"],
script.Parent["Frail Lure"],
script.Parent["Paper Lure"],
script.Parent["Copper Lure"],
script.Parent["Swift Lure"],
script.Parent["Blessed Lure"]
}
for _, lure in pairs(lures) do
createRot(lure)
end
but still you could make it better via making all the part spin in just one heartbeat but it just a demo i didnt test it
local timeForFullCycle = 1.5
local targetRotPerCycle = 360
local partsToRotate = {
script.Parent["Corroded Lure"],
script.Parent["Begginner's Lure"],
script.Parent["Frail Lure"],
script.Parent["Paper Lure"],
script.Parent["Copper Lure"],
script.Parent["Swift Lure"],
script.Parent["Blessed Lure"],
}
game["Run Service"].Heartbeat:Connect(function(delta)
local rot = (targetRotPerCycle/timeForFullCycle)*delta
for i,v in partsToRotate do
if v:IsA("BasePart") then
v.Orientation += Vector3.new(0, rot, 0) -- modify the axis to your needs
end
end
end)
This should rotate the parts in partsToRotate for each heartbeat.