Trying to make a part rotate on a pivot

Hi I am currently trying to make a ball open and close when a player clicks on it, however the top part of the ball needs to rotate 90 degrees on the pivot point to open correctly and I have absolutely no idea how to go about doing this.

I have set the parts pivot point to the front bottom of the part so its right on where it should rotate, and i have even tried adding a small part in the same spot to try and get it to pivot around the part but this also didn’t work as intended.

Any help to point me in the right direction would be greatly appreciated
image
(image shows the closed ball and the open ball with the pivot part visible on the open ball)

2 Likes
local cframeValue = Instance.new("CFrameValue")
local openPart = -- path to open part

game.TweenService:Create(cframeValue, TweenInfo.new(2), {Value = CFrame.Angles(0, 0, -math.pi / 2)}):Play()

local originalPivot = openPart:GetPivot()

cframeValue:GetPropertyChangedSignal("Value"):Connect(function()
	openPart:PivotTo(originalPivot * cframeValue.Value)
end)

image
Assuming the pivotpoint is here.

5 Likes

How would I go about making this go the opposite way and return to its open position?

2 Likes

game.TweenService:Create(cframeValue, TweenInfo.new(2), {Value = CFrame.Angles(0, 0, math.pi / 2)}):Play()
same thing except the inverse the sign for the rotation

3 Likes

make another tween and play it inversely

game.TweenService:Create(cframeValue, TweenInfo.new(2), {Value = CFrame.Angles(0, 0, math.pi / 2)}):Play()
2 Likes

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