Idk what to call the problem Im trying to solve…
-
What do you want to achieve?
I want a rotation system that will rotate the currentPiece around the origin of the Piece. -
What is the issue?
when I rotate the currentPiece the piece rotates around the center instead of the origin (I set the origin to where I want to rotate the piece, but when the script rotates the piece, it rotates in the center) -
What solutions have you tried so far?
I’ve tried setting the origin but the script doesn’t rotate around it.I’ve also tried using a pivot point variable where it’s a vector3 and it specifies where it should rotate and then using that point to rotate the piece around, but that doesn’t work.
here is the script I use to rotate the piece.
local currentPiece = workspace.CurrentPiece:GetChildren()[1]
local newOrientation = currentPiece.Orientation
script.Parent.MouseButton1Click:Connect(function()
-- rotate the piece by 90 degrees around the X axis
local rotation = CFrame.Angles(math.rad(90), 0, 0)
-- Rotate the current piece by the rotation
currentPiece.CFrame = currentPiece.CFrame * rotation
newOrientation = currentPiece.Orientation
print("valid rotation")
end)
here are some images explaining the problem:
what I want it to do
what the script does
notice how when the script rotates the piece it goes off-grid, but I always want to stay ‘connected’ to the grid.
hopefully, I’m not asking for a lot, and I have no idea how complex it could get. I’ve been working on this script for a few days now.
Thanks, Brant