Spinning meshes help

I’m incredibly new to scripting, and I’m trying to get one of my meshes to spin. This code works on parts, but not meshes.

while true do
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(.1,.1,.1)
wait()
end

Does anyone know what I’m doing wrong?
Thanks in advance.

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?

It’s only a singular model, and that’s it. The model stays stationary. How would I use a tween?

There are many posts on Tweening Models.

It’s actually very simple, and the Mesh isn’t to blame. It is just that you need to Tween the whole model.

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.


do not weld it, it wont spin if you weld it, just anchor it, that will keep it in the same position.

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;

he is only wanting the mesh sphere to spin not all the other parts.

It’s still now wanting to work, is there anything that I could be doing wrong?

make sure CanCollide is off, make sure your part is not welded and make sure your part IS anchored, the code should work fine, I use it all the time.

a server script for a rotating animation? that’s not correct @GRADE_1000 don’t do that lol.

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.

As fare as i can see the script is a localscript in workspace. I am refering to the images that he sendt.

Localscripts wont run when they are in workspace, he has to place the script in starterPlayerScripts or StarterGui

It’s still not working and I have made sure all of these statements are true.

Just place the script in StarterPlayerScripts and change the part variable to the parts location in explorer

Correct me if I’m wrong, but wouldn’t using a BodyAngularVelocity be another way to achieve this?

It could work, but then you would have to use a bodyGyro to keep it in place.

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.

1 Like