Properly rotating a model based on mouse position

Trying to accomplish:
I’m trying to make a model rotate on its x, y, and a axis based on the mouse.hit position.

Issue:
I currently have it set up to where it fires an event that sends the mouse.hit position to a server script. And from the server script, it manipulates the models primaryparts orientation based on the mouse.hit. However; the moment I move my mouse the model begins to spaz out and eventually gets deleted from the world.

Solutions:
I’ve tried using SetPrimaryPartCFrame but this gave the same results.

local script:
LocalScript.lua (245 Bytes)

server script:
Script.lua (313 Bytes)

1 Like

Is the model anchored when you move it? Make sure that it is.

Also it’s hard to help you without seeing your code, so please post it!

My bad, I just uploaded both the local and server script. And no, the model nor the parts in it are anchored.

  1. You should set blades’s PrimaryPart before even running the script. blades.PrimaryPart = blades.Handle isn’t necessary.

  2. Don’t set the CFrame of the model’s PrimaryPart with model.PrimaryPart.CFrame = blah. If the rest of the parts of your model aren’t welded to the PrimaryPart, then they won’t rotate with it. Do model:SetPrimaryPartCFrame(blah) instead.

  3. There’s another CFrame constructor, CFrame.new(p, lookAt), which creates a CFrame that is positioned at p, oriented so that its front faces lookAt. Try setting the CFrame of blades’s PrimaryPart to CFrame.new(blades.PrimaryPart.Position, mouseHit) and see if that gets you closer to solving your problem.

3 Likes

Okay thanks! I’ll give this a try.

Sorry for the super late response, but it works perfectly! Thank you so much!

1 Like