Also i suggest using Tween.Completed:Wait() instead of the wait(), it’ll wait until the tween is complete before it starts running the rest of the code
I believe the problem is from using Rotation instead of CFrame. The math might be a little weird since the TweenService interpolates linearly and rotations aren’t exactly a “vector” value in anything but form.
Using CFrames should probably solve the problem.
local TweenService = game:GetService("TweenService")
local inputService = game:GetService("UserInputService")
local part = script.Parent.Parent.right
local initialCFrame = part.CFrame
-- initialCFrame rotated 90 degrees
local finalCFrame = part.CFrame * CFrame.Angles(0, math.rad(90), 0)
local info = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local isPlaying = false -- Added this, you can remove it.
script.Parent.Triggered:Connect(function()
if isPlaying then return end -- added
isPlaying = true -- added
local Goals =
{
CFrame = finalCFrame
}
local tween = TweenService:Create(part, info, Goals)
tween:Play()
task.wait(4)
local Goals =
{
CFrame = initialCFrame
}
local tween = TweenService:Create(part, info, Goals)
tween:Play()
tween.Completed:Wait()
isPlaying = false -- added
end)