Meshpart is not rotating properly in script

Hi! Basically, I am trying to make a meshpart shaped like a star that spins round and round, with a script inside the meshpart to do it. However, when i run the game it rotates the wrong way, rotating upright rather than on its side and no, this is not a problem with the way I rotate the part in the script as it works perfectly fine with the other part. Here is all the stuff in my workspace, simple two parts (The meshpart with a script inside and a part with the same script to test whether its the script or the meshpart that is wrong):

image

As you can clearly see in the image, it is just the part (left) and the meshpart (right). And, that they are BOTH flat on the side (horizontal), so as they have the same script and the part on the left spins fine horizontally, they should both spin horizontally.

The script basically makes the parts spin horizontally, but the meshpart weirdly spin vertically with the same script. This is the script (same script in both parts):

Local part = script.Parent
Local a = 0
repeat
    part.Rotation = Vector3.new(0, a, 0)
    wait(.01)
    a = a + 10
until piggs == 1 --IMPORTANT! The piggs variable is undefined by me as I want it to have no value so the part keeps on spinning. Basically to keep it from not meeting the condition that will stop it rotating.

Here is a video of whats going wrong (So sorry about the lag :grimacing:):

robloxapp-20210128-1416027.wmv (1.0 MB)

As you can see, the part on the left with the same script rotates fine horizontally, but the meshpart rotates vertically instead. Is this an issue with the meshpart being anchored, it being a meshpart or something else, as it works fine on the other part with same script.

Basically, in short is that both parts before I test are both horizontal, flat on their side. However, when I test the game, the meshpart (star) is rotating vertically, even though the script makes it rotate horizontally and that with the same script the other part is rotating fine horizontally.

Any help would be super appreciated!!!
Thanks a lot!

1 Like
local part = script.Parent --[[ Do not us Local use local]]

local a = 0

while true do --[[ Instead of doing repeat use while true do ]]

part.Orientation = Vector3.new(0, a, 0) --[[Use orientation not rotation]]

wait(.01)

a = a + 10

end
2 Likes

Thanks so much for the response! Sadly still same thing, still spins horizontally. Should I try recreate it as similar as possible but just as part (multiple normal part grouped together into a model). I have a feeling that its the issue with the meshpart as the other one works fine as it spins horizontally, whereas the meshpart (star-shaped) one spins horizontally.

Thanks so much for the help though! Really appreciated!

1 Like

try moving a from the second argument to other arguments, could be weird mesh rotation? what’s the current mesh rotation

That would move it backward? You could try Changing where a will be in the Vector3

local part = script.Parent --[[ Do not us Local use local]]

local a = 0

while true do --[[ Instead of doing repeat use while true do ]]

part.Orientation = Vector3.new(a, 0, 0) --[[Use orientation not rotation]]

wait(.01)

a = a + 10

end

That rotates differently then before spot the difference where Vector3.new(a, 0, 0) is it was before Vector3.new(0, a, 0)

Mesh Part may not have the same surface as parts, as you can see in the GIF below the yellow motor represents the top surface.
https://gyazo.com/6ed936f89baffb31ec92646da43282fb

So if you want the mesh part to be pointing horizontally, try to mess around with the axis till you get your preferred orientation.
https://gyazo.com/ef010c7e8b910008225574ffa9ed88c8

local part = script.Parent
local a = 0

while wait(0.01) do
	part.Orientation = Vector3.new(90, a, 0) 
	a = a + 10
end