Woah! Why use a while loop for this when you can tween? Also, can you provide us GIFs of what it does when implemented on a Mesh, and what are the components of the Mesh? Are you trying to do this to a model? Or several meshes?
make the mesh spin in a local script and use RunService’s RenderStepped event,
you do not have to tween this as tweening would be overkill for a simple rotation.
EDIT: if your rotating an ENTIRE model. (not a single mesh part) then you need to rotate the Models PrimaryPart
EDIT2: You can also use CFrame.Angles instead because its exactly the same as fromEulerAnglesXYZ just shorter.
local rs = game:GetService("RunService")
local part = script.Parent
--rotates the parts' Y Axis by 5 radians every frame.
rs.RenderStepped:Connect(function()
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(5), 0)
end)
It’s not working for me. I want to keep the mesh in the same location, but make it spin. I have tried anchoring the part and inserting this script and I’ve tried welding it to keep it in the same location.
You need to make this a model then and tween them all as a model. Welding it and anchoring it is a lot less efficient than just putting them all into 1 model, and all of them being parented to the model. And then using this method to Tween it to spin;
No. The server doesn’t need to render the spinning for all the clients. The client can do their own work, this is a lot less laggy and uses less memory if you use a local script instead of a Server Script for this job.
You would actually have to use a BodyPosition to keep it in place, rather than a BodyGyro. It wouldn’t be too hard to have a BodyPosition make it stay in one place.