Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I gradually rotate a part using radians?

repeat wait() until script.Parent.PlayerVal.Value ~= nil
script.Parent.PlayerVal.Value.RemoteEvent.OnServerEvent:Connect(function()
	script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, script.Parent.Orientation.Y + math.rad(5),0)
wait(0.1)
end)

When I try this it does not turn the right amount, maybe i am using radians wrong? I want script.parent to rotate 5 degrees every time the event triggers

1 answer

✓ Accepted answer

Essentially, you're adding the current orientation of the part to the current orientation of the part + 5 degrees, which will not turn out how you would expect. Here's a fix:

repeat wait() until script.Parent.PlayerVal.Value ~= nil
script.Parent.PlayerVal.Value.RemoteEvent.OnServerEvent:Connect(function()
    script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(5), 0)
end)

You also have an unnecessary wait there, so I removed it

This discussion is preserved as it was. New answers, comments, and votes are closed.