Hello, I’m looking to make a tween service script to optimize the latency of my game. The tween starts as soon as the player touches a part and stops as soon as he touches another part (and at this moment the object goes back to its initial position to allow the player to do the parkour again). Except that I have the impression that the fact of teleporting the part cancels the tween service permanently and thus this one does not function any more once the player made the parkour once. Is there a way to make the tween work as many times as the player wants to do the parkour? Thank you
local plr = game.Players.LocalPlayer
local ts = game:GetService("TweenService")
local p1 = game.Workspace.avion1b
local p2 = game.Workspace.avion2b
local ball = game.Workspace.heliceb
local stop = game.Worskace.Stop
local TweenInformation = TweenInfo.new(
17,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
true,
2
)
local Tween = ts:Create(ball, TweenInformation, {Position = p1.Position})
local Tween2 = ts:Create(ball, TweenInformation, {Position = p2.Position})
function onTouch(hit)
if hit.Parent.Name == plr.Name then
ball.CanTouch = false
wait(2)
Tween:Play()
Tween2:Play()
end
end
ball.Touched:Connect(onTouch)
function onTouch(hit)
if hit.Parent.Name == plr.Name then
Tween:Cancel()
Tween2:Cancel()
ball.CFrame = CFrame.new(107.053, 643.35, -53.407)
end
end
stop.Touched:Connect(onTouch)