Hello, I am wondering why is my tween delaying? I want to make the GoalAction start immediately after I touch the part, but 1. It doesn’t and 2. Apparently the script is still running, so sometimes the part just gets destroyed without it playing the tween.
local TweenService = game:GetService("TweenService")
local part = script.Parent
local isTweenRunning = false
local PositionSpinning = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
-1,
false,
0
)
local Goals =
{
Orientation = Vector3.new(0,360,0);
Position = Vector3.new(-23.076, 7.999, -11.668)
}
local GoalAction = TweenService:Create(part, PositionSpinning, Goals)
wait(1)
local TweenService = game:GetService("TweenService")
local function rotateFync()
local Part2 = script.Parent
local RotationSpeed = 3
local tweeninfo = TweenInfo.new(RotationSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local goal = {CFrame = Part2.CFrame * CFrame.Angles(0, math.rad(120), 0)}
local rotatepart = TweenService:Create(Part2, tweeninfo, goal)
rotatepart:Play()
rotatepart.Completed:Connect(rotateFync)
end
rotateFync()
local Connection
Connection = part.Touched:Connect(function(OtherPart)
local Character = OtherPart:FindFirstAncestorOfClass("Model")
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player then
if not isTweenRunning then
GoalAction:Play()
wait(1)
part:Destroy()
end
end
end)