BunnlyYt
(BunnlyYt)
April 3, 2024, 10:50am
#1
Hello, I have a grab system and I have a problem. The problem is, I want the part being grabbed to face the player with the rotation it had before being grabbed. The code I tried works horizontally but not vertically. The vertical rotation only rotates in one direction.
local rx, ry, rz = (CFrame.lookAt(character.Head.Position, grabbedPart.Position)):ToOrientation()
grabbedPart.Orientation = grabbedPartBaseOrientation + Vector3.new(math.deg(rx),math.deg(ry),math.deg(rz)) - baseOrientation
The rx, ry, rz is the rotation of the head facing the part being grabbed. The grabbedPartBaseOrientation is the orientation of the part being grabbed before it was grabbed. baseOrientation is rx, ry, rz but before it was grabbed.
2 Likes
wastbo
(DanCodes)
April 3, 2024, 12:48pm
#2
Try just doing
(CFrame.lookAt(grabbedPart.Position, character.Head.Position) * savedRotation).Rotation
Saved rotation should be the CFrame.Rotation of the part when it is picked up
3 Likes
BunnlyYt
(BunnlyYt)
April 3, 2024, 11:49pm
#3
That didn’t work. Rotation doesn’t exist for that.
1 Like
wastbo
(DanCodes)
April 4, 2024, 12:36am
#4
The part doesn’t have a CFrame?
1 Like
BunnlyYt
(BunnlyYt)
April 4, 2024, 1:15am
#5
It does (blahblahblah roblox text min max thing)
1 Like
wastbo
(DanCodes)
April 4, 2024, 2:59am
#6
Then make a variable called saved rotation and set it to the part’s CFrame.Rotation
1 Like
BunnlyYt
(BunnlyYt)
April 4, 2024, 3:28am
#7
Now this happens but it’s very close!
1 Like
BunnlyYt
(BunnlyYt)
April 6, 2024, 1:24am
#8
I did this but didn’t do it correctly but I did it correctly but the problem above happens.
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 8:58pm
#9
It’s been a whole week why won’t anyone help?
1 Like
Den_vers
(Den_vers)
April 13, 2024, 8:58pm
#10
Do the same thing but remove the x rotation.
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 8:59pm
#11
what? can you explain more?
IGNORE IGNOre
1 Like
Den_vers
(Den_vers)
April 13, 2024, 9:01pm
#12
Do exactly what you’re doing, but remove the x rotation of whatever CFrame you’re setting the part to. It’s simple:
local _, y, z = part.CFrame:ToOrientation()
part.CFrame = CFrame.fromOrientation(0, y, z)
or you could do:
part.CFrame = CFrame.fromOrientation(0, select(2, part.CFrame:ToOrientation()))
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 9:09pm
#13
Removing X rotation makes the part not rotate
1 Like
Den_vers
(Den_vers)
April 13, 2024, 9:10pm
#14
Rotate the part and then do this line of code.
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 9:14pm
#15
This is the problem with the video above:
mousePosPart.CFrame = CFrame.new(mousePosPart.Position) * (CFrame.new(mousePosPart.Position, character.Head.Position) * CFrame.Angles(grabbedPartBaseRX,gpbrY,gpbrZ)).Rotation
mousePosPart is the part being grabbed.
grabbedPartBaseRX,gpbrY,gpbrZ are the rotation of the part when first grabbed.
1 Like
Den_vers
(Den_vers)
April 13, 2024, 10:09pm
#16
BunnlyYt:
CFrame.new(mousePosPart.Position) * (CFrame.new(mousePosPart.Position, character.Head.Position) * CFrame.Angles(grabbedPartBaseRX,gpbrY,gpbrZ)).Rotation
Ok, like I said before, do this exact same code, but remove the x rotation using the code I provided earlier:
local cframe = CFrame.new(mousePosPart.Position) * (CFrame.new(mousePosPart.Position, character.Head.Position) * CFrame.Angles(grabbedPartBaseRX,gpbrY,gpbrZ)).Rotation
mousePosPart.CFrame = CFrame.fromOrientation(0, select(2, cframe:ToOrientation()))```
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 10:14pm
#17
Now it does the same thing with the same problem but Vertical movement works now
1 Like
Den_vers
(Den_vers)
April 13, 2024, 10:19pm
#18
Can you send a video? I don’t quite understand what you mean.
1 Like
BunnlyYt
(BunnlyYt)
April 13, 2024, 11:53pm
#19
Oh wait the vertical rotation broke.
1 Like
Den_vers
(Den_vers)
April 14, 2024, 12:16am
#20
Do you want it to just follow the mouse, no rotation? I’m having trouble understanding.
1 Like