A minor issue was that you didn’t use the UserInputService correctly. You need the input parameter when firing the function but I fixed that for you.
Mainly, you are currently trying to use a deprecated method to load animations.
Humanoid:LoadAnimation() and AnimationController:LoadAnimation() were deprecated about 3 years ago. Overall Roblox is trying to remove Animation controllers as they have to be kept for “historical reasons” as official staff say.
The modern method to load an animation is using an Animator which is automatically included in a characters Humanoid.
Your code should look like this:
local UserInputService = game:GetService("UserInputService")
local char = script.Parent
local hum = char:FindFirstChild("Humanoid")
repeat wait() until hum
local animator = hum:FindFirstChild("Animator")
repeat wait() until animator
local alotofpunches = script.rapidpunchanim
local alotofpunchesloaded = animator:LoadAnimation(alotofpunches)
local debounce = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
if debounce == false then
hum.WalkSpeed = 0
alotofpunchesloaded:Play()
wait(3)
hum.WalkSpeed = 16
alotofpunchesloaded:Stop()
debounce = true
wait(5)
debounce = false
end
end
if input.KeyCode == Enum.KeyCode.F then
if debounce == false then
print("Punches")
debounce = true
wait(1)
debounce = false
end
end
end)
Announcement about deprecation of some LoadAnimation methods:
LoadAnimation documentation of Roblox: