So basically, I have an item rotation system and it rotates the item on it’s CFrame, but for example once I turn them randomly, when I click a left button to rotate it left, the item will rotate Up. I tried to instead rotate it on it’s Vector3 but the same issue occured. Any ways I can fix it, so that it always rotates logically? (e.g When I press a up button it always rotates Up)
Here’s my code:
local Direction = c:FindFirstChildWhichIsA("StringValue")
if Direction and debounce == false then
debounce = true
local rotateTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local currentOrientation = PickedItem.Orientation
if Direction.Name == "Up" then
local rotateUpTween = tweenservice:Create(PickedItem, rotateTweenInfo, {CFrame = PickedItem:GetPivot() * CFrame.Angles(math.rad(-90),0,0)})
rotateUpTween:Play()
--PickedItem:PivotTo(PickedItem:GetPivot() * CFrame.Angles(math.rad(-90), 0, 0))
elseif Direction.Name == "Down" then
local rotateDownTween = tweenservice:Create(PickedItem, rotateTweenInfo, {CFrame = PickedItem:GetPivot() * CFrame.Angles(math.rad(90),0,0)})
rotateDownTween:Play()
--PickedItem:PivotTo(PickedItem:GetPivot() * CFrame.Angles(math.rad(90), 0, 0))
elseif Direction.Name == "Left" then
local rotateLeftTween = tweenservice:Create(PickedItem, rotateTweenInfo, {CFrame = PickedItem:GetPivot() * CFrame.Angles(0,0,math.rad(90))})
rotateLeftTween:Play()
--PickedItem:PivotTo(PickedItem:GetPivot() * CFrame.Angles(0, 0, math.rad(90)))
elseif Direction.Name == "Right" then
local rotateRightTween = tweenservice:Create(PickedItem, rotateTweenInfo, {CFrame = PickedItem:GetPivot() * CFrame.Angles(0,0,math.rad(-90))})
rotateRightTween:Play()
--PickedItem:PivotTo(PickedItem:GetPivot() * CFrame.Angles(0, 0, math.rad(-90)))
end
end
Thanks! ![]()