what i want to achive : make the stand return to its original position after 1.3 seconds of it moving but m1ing resets the timer to 1.3 again
the problem :
when i m1 once everything works perfectly but when i m1 multiple times instead of the timer reseting everytime i m1 what happens is that with each m1 it starts to count down from 1.3 seconds a again while keeping the frist time existing like if the first m1 has 0.5 seconds left and i m1 again the 0.5 still keeps counting down and the second m1 starts counting down aswell so i have two counting at the same time and when one finishes it launches the script to return the stand
what i tried :
i’ve looked for similar topics and all of their solutions were to use a break in the loop but it didnt work for me
here is the code for it
local m1Debounce = false
local active = false
length = 1.3
input.InputBegan:Connect(function(inputobject, typing)
if typing == true then
return
end
if inputobject.UserInputType == Enum.UserInputType.MouseButton1 then
if m1Debounce == false then
print("m1")
length = 1.3
m1Debounce = true
local StandTween = Tween:Create(plr.Character.Motor6D, TweenInfo.new(0.3), {C1 = CFrame.new(0, -0.3, 3)} )
StandTween:Play()
if active == false then
active = true
end
task.wait(.3)
m1Debounce = false
end
while active == true do
if length <= 0 then
local StandReturnTween = Tween:Create(plr.Character.Motor6D, TweenInfo.new(0.3), {C1 = CFrame.new(-2, -0.3, -2.5)} )
StandReturnTween:Play()
print("StandReturns")
active = false
break
else
task.wait(.1)
length = length - 0.1
print(length)
end
end
end
end)