Rotate around the origin using a script?

Idk what to call the problem Im trying to solve…

  1. What do you want to achieve?
    I want a rotation system that will rotate the currentPiece around the origin of the Piece.

  2. 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)

  3. 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

	-- 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")

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

1 Like

Try putting them in a group and set the PrimaryPart to the Middle block

Also making a tetris related game sticling to the tetris guidelines are hard, trust me I’ve done it but it’s hard.

1 Like

A simple fix to this would be to move the origin point itself to the middle of the middle block.

I dont think it would work like that, cause I also need all the other blocks to rotate correctly as well.

sorry for the late reply, but it works now. YAY. I never knew that if you set a primary part it will move around that instead of the middle. Thank you so much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.