TweenService:Create(script.Parent.Map.MapBorder,TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), {CFrame = CFrame.new(script.Parent.Map.MapBorder.CFrame.Position + Vector3.new(0,1,0))}):Play()
while task.wait() do
script.Parent.Map.MapBorder.CFrame = CFrame.new(script.Parent.Map.MapBorder.Position) * CFrame.Angles(0, math.rad(4),0)
end
I want the position to slowly go up and down (which is already achieved)
But i want the object to rotate continuously in one direction without reversing, and the issue is for the position the final boolean (reverse) is true and i don’t want that for the rotation. If you are asking why i don’t use position, it’s because welds don’t work with positions
Anyone have ideas how i can do them separately?
It rotates the 4 degrees from the beginning of the animation and at the end its back at 0, then goes to 4 and repeat
Its caused because your doing the tween on the CFrame and not the Position.
local Part = script.Parent
-- Repeatable Up and Down movement tween; can be achieved by using math.sin too...
game:GetService("TweenService"):Create(
Part,
TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{Position = Part.CFrame.Position + Vector3.new(0,1,0)}):Play()
-- Rather do this on RenderStepped in a client script.
game:GetService("RunService").Heartbeat:Connect(function(delta)
local CurrentCF = Part.CFrame
local FinalCF = CurrentCF * CFrame.Angles(0,math.rad(4),0)
-- Doing this adds visual consistency
Part.CFrame = Part.CFrame:Lerp(FinalCF, delta*20)
end)
-- Alternativly
--[[
local OriginPosition = Part.Position
game:GetService("RunService").Heartbeat:Connect(function(delta)
local floatY = math.sin(os.clock() * 5) * 2
local rotationY = os.clock() * math.rad(240) -- 240 degrees per second rotation
local targetCF = CFrame.new(OriginPosition + Vector3.new(0, floatY, 0)) * CFrame.Angles(0, rotationY, 0)
Part.CFrame = Part.CFrame:Lerp(targetCF, delta * 20)
end)
--[[]]
Yes. although remember that tweens are quite limited since they’re called once so when it reverses the rotation will go in the other way, also even in a separate tween, we would need reset the Orientation Y from 360 to 0 every time it finishes.
But there’s always a better way to do that with some simple math.
I dont think so there is a way to make a tween last forever if you set the repeat to -1 then i believe it would repeat forever and you wouldnt have to change the rotation but maybe im wrong
At this point I’d say you’re better off just making the tween yourself. It’s not complicated, every frame, get t (number from 0 to 1 representing how far the tween is, 0 meaning just started and 1 meaning finished)
local t = (time() - startTime) / tweenTime
And then just update the properties you want using t
part.CFrame = startCFrame:Lerp(endCFrame, t)
And if you don’t want the tween to be linear, just pass it through an easing function
t = EaseOutQuad(t)
(You can find easing functions and their implementations one the site “Easing functions cheatsheet” (google it) or just ask chatgpt
This way you can make the tween do exactly what you want, or combine a positional and rotational tween.
OR if you really want to (personally wouldn’t recommend it, but you can do it too) you can do two separate tweens on CFrameValues and then update your object every frame according to those.