Im trying to make a part rotate when clicked, im using TweenService and when i click it, it like spins around a bunch before going to its final destination, im trying to make it turn 45 degrees each click, heres my script:
local TweenService = game:GetService("TweenService")
local part = script.Parent
local clickDetector = part:WaitForChild("ClickDetector")
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
false,
0
)
local currentRotation = part.Orientation
local function rotatePart()
local targetRotation = currentRotation + Vector3.new(0, 45, 0)
local tweenGoal = {
Orientation = targetRotation
}
local tween = TweenService:Create(part, tweenInfo, tweenGoal)
tween:Play()
tween.Completed:Connect(function()
currentRotation = targetRotation
end)
end
clickDetector.MouseClick:Connect(rotatePart)