How can I calculate the rotation for this?

I want the part to keep its original rotation but also rotate WITH the player.

1 Like

You want it to move around with the mouse, but keep itā€™s rotation?

1 Like

Yes 298472984729834729847239472424

1 Like

Simple, you donā€™t need a rotation.

Just set the CFrame of the part to the position you want it at, excluding the CFrame. Like this:

part.CFrame = CFrame.new(cframeOfRaycast.Position)

This will exclude rotation.

1 Like

If this moves the part without rotating it, thats not what I want. I want the part to rotate WITH the player so if the player picks it up, the part will face the player with its orignal rotation from when it was first picked up

1 Like

Okay, so save the rotation of the player when they first pick it up, and set it to the position of the raycast, and then multiply it by the .Rotation of the CFrame you saved.

1 Like

It didnā€™t work I think. Can you give me code and explain how it works?

1 Like

Itā€™s simple. Save the CFrame of your character when you first pick it up, get the position that you want to set the part to, put that position into a new CFrame, and then multiply that cframe by the .Rotation of the CFrame you saved.

1 Like

I donā€™t want the part to rotate when it gets grabbed. I want it to rotate when it is moving/being dragged. So a start rotation(the rotation of the part when it got grabbed) and it rotating along with the direction of the player.

1 Like

So you want it it to only follow the Y rotation of the character, while itā€™s moving? Simple, get the Y rotation of the character, and multiply it by the parts CFrame

local _, y, _ = character:GetPivot().Rotation:ToOrientation()
part.CFrame *= CFrame.new(mousePosition) * CFrame.Angles(0, y, 0) 
1 Like

No not just the Y rotation. The original problem was me not being able to make the Y rotation work. I want all rotation axis to work.

1 Like

It would save an awful lot of time if you could post the place for people to mess around with, otherwise we have to write a grabbing system and test methods of fixing it ourselves (which wonā€™t fix yours!). Without that all we can do is make our own grabber system to play around with. Or even worse, mentally visualise solutions that might work for your grabber system, then type them out to you as a reply, and then wait for a response.

1 Like

Itā€™s SOOO hard to understand what youā€™re saying without an example, Iā€™ve tried to write a script for every combination of everything you could possibly be wanting, and itā€™s not what you want, can you find an example?

1 Like


this is what I want.
TestPlace.rbxl (63.3 KB)
and a file

i gtg now so ill be back later

Thatā€™s great, thank you. The issue is the method you chose to click and activate the block. We might chose a different method and will struggle to help with your system. Iā€™ll have a tinker now.

local playerPosition = character.Head.Position
local grabbedPartPosition = grabbedPart.Position

local lookAtCFrame = CFrame.lookAt(playerPosition, grabbedPartPosition)
local lookAtOrientation = lookAtCFrame:ToOrientation()

local lookAtOrientationDegrees = Vector3.new(math.deg(lookAtOrientation.x), math.deg(lookAtOrientation.y), math.deg(lookAtOrientation.z))

local orientationDifference = lookAtOrientationDegrees - baseOrientation
grabbedPart.Orientation = grabbedPartBaseOrientation + orientationDifference

Ngl anytime thereā€™s a CFrame question on this forum I just use google n copy n paste n hope it works or close enough because bro CFrame should not be this hard but it is.

This is WAYYY too over complicated. Simply use this:

part.CFrame = CFrame.new(mousePos, character:GetPivot().Position)

No they want it based on the characters looking direction not where the mouse is. I think, unless I misunderstood the question?

He knows what Iā€™m talking about, wherever heā€™s casting and getting the position to set the part to, thatā€™s mousePos.

Iā€™m not sure you understand how this function works, because thatā€™s exactly what it does.

380e19f597c5691c6e242b4988afe4012e302e7f