Hi, first post, please excuse any mistakes i make.
So, i’m making a script that tracks for how long a button is being pressed, and stops an animation using AnimationTrack:Stop() using that amount of time.
The problem is, it delays the animation from stopping for the amount of time that is being used.
For example:
I want the animation to stop, but i want it to take 3 seconds for it to stop.
So i use:
AnimationTrack:Stop(3)
But when i enter that, it waits 3 seconds, and after that it also takes 3 seconds to stop.
So it practically works but also doesn’t?
I don’t understand a bit of what i have to do to fix it. And it has been bothering me for a couple of days.
Here’s the relevant part of the script for reference:
local secondsheld = 0
local inputservice = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5055476251"
local animationtrack = char.Humanoid:LoadAnimation(animation)
animationtrack:Play()
inputservice.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
repeat
wait(.1)
secondsheld = secondsheld + .1
until inputservice:IsKeyDown(Enum.KeyCode.W) == false or secondsheld >= 5
animationtrack:Stop(secondsheld) --Part where it delays
end
end)
If you have any further questions, please feel free to ask.
-Spectro