How do I make a Model (With a mesh) Spin?

I’m not a scripter, I don’t know how to script. The following script here was made by my friend whos experienced in coding.

rot = .4
while true do
script.Parent.Rot1.CFrame=script.Parent.Rot1.CFrame*CFrame.fromEulerAnglesXYZ(0,rot,0)
wait()
end

This code however only works on parts, not models/meshes. My object I’m trying to rotate is a model with 2 models in it with a mesh part in each model:
image

I am trying to make my fishes spin (to make it look like they are swimming)


I am aware that there was already a topic similar to this already posted on the forums but there was no solution to it. Can someone who has experience in spinning meshes help me out?

5 Likes

Try putting the models (Koi fishes) with two separate parents, then set a primary part for each model.

You can achieve this by welding the meshes to a main part and rotating that.

Hey, if you already figured out a way to do it awesome, I know I’m 6 hours late at the time of posting this. But one thing you can use is the PrimaryPart feature of models.

Set the primary part to a part in the middle of the Koi fish then change your code to the following.

local fish = workspace:FindFirstChild("Koi Fishes")
local rot = 0.4

game:GetService("RunService").Heartbeat:Connect(function()
  local newCFrame = fish:GetPrimaryPartCFrame() --Get our current CFrame for the model
    * CFrame.fromEulerAnglesXYZ(0, rot, 0)  --Add the new rotation to it
  fish:SetPrimaryPartCFrame(newCFrame) --Set our new CFrame
end)
5 Likes

You should set the PrimaryPart to one fish and weld them two. Anchor only the PrimaryPart.
From now on , all you need to use is CFrame, as colbert’s tutorial said.

I think you need to make union with fishes and on part that will be rotating , the you need to make hinge and in properties change priority to motor then change rotate speed that you want .

You cant union meshes in studio.

I read the code and it should work but it didn’t. I have everything in place as you said, and i made the the primary part the primarypart. Did i do something wrong? Is there something that needs to be unachor / can collide
image

I mean you can add part make on that part hinge and add that part into this fishes

Is your script inside of the Fishes?

If so, there will be no need for local fish = game.Workspace.KioFishes, just local fish = script.Parent

@MrLonely1221 This is the error message, somethings wrong with line 4. image

Your code had an error, The function wasnt connected. The “end)” should be “end” not )

1 Like

Thank you, I didn’t realized it before. Don’t script in the dev forum text box kids.

1 Like