Pausing and continuing a Charging Up animation for skills

Currently, I’m working on a fighting game with skills, and certain ones you can hold down. Some of them can be held down, and once it reaches the max hold time, it’ll automatically fire. For some basic info, you press a letter and the local script detects that and fires a remote event which a normal script detects and does the skill.

My main problems:
I don’t know how I’d constantly detect if the button is being held down and if it is, I don’t know how I’d make it play an animation, pause that animation whilst it’s held down, and gotten to a certain point and continue the animation when the button isn’t being held down.

I’d appreciate any help with this! :smile:

3 Likes

I’m guessing you’re using user input service and there’s actualy function called .InputEnded

then by using time() you can find the start time and after a certain point you can resume the animation and for the pausing use animation:AdjustSpeed(0)

Some code examples:

local holding = false
local start = time()

UserInputService.InputBegan:Connect(function()
   holding = true
   start = time()

   while holding do
         if time() - start > maxTime then

         end
         task.wat()
   end
end)

UserInputService.InputEnded:Connect(function()
   holding = false
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.