Constant 360 Rotation

I looked for this, couldn’t find it.

I’m trying to Rotate a Model, constantly at a reasonable speed. Using CFrame and PrimaryPart, along with the model also “floating”… This is what I have, but it’s not going in the direction I’d like and it’s not going a full 360.

local TweenService = game:GetService("TweenService")
local FloatTInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, -1, true, 0)

local Model = script.Parent
local PrimaryPart = Model.PrimaryPart

local function Rotation()
	while wait(.1) do
		Model:SetPrimaryPartCFrame(PrimaryPart.CFrame * CFrame.Angles(1, 1, 1))
	end
end

TweenService:Create(PrimaryPart, FloatTInfo, {CFrame = PrimaryPart.CFrame * CFrame.new(0, .25, 0)}):Play()
Rotation()

Looking around a bit more, I found I should change my code to this…

Model:SetPrimaryPartCFrame(PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, .1, 0))

Did that but the model won’t spin completely and does a weird jump every now and then.

2 Likes

Try rotating the primary part using RunService.Heartbeat, on the client

local part = model.PrimaryPart
local runService = game:GetService("RunService")

local function onHeartbeat()
    part.CFrame *= CFrame.fromEulerAnglesXYZ(0, 0.1, 0) -- *= combined operator
    -- you could use the time between the previous frame and this one, dt in your function too - not necessary though
end
runService.Heartbeat:Connect(onHeartbeat)
1 Like