local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local debounce = false
UserInputService.InputBegan:Connect(function(input, isProcessed)
if isProcessed then
return
end
if input.KeyCode == Enum.KeyCode.E then
if debounce then
return
end
debounce = true
game.ReplicatedStorage.CombatHit:FireServer()
local animation = Instance.new("Animation")
animation.AnimationId = "17017381266"
local animTrack = player.Character.Humanoid:LoadAnimation(animation)
animTrack:Play()
print("E key is pressed")
wait(3)
debounce = false
end
end)
I haven’t completed the script yet so I can test it and later on I’m going to complete this script
Just as @12345koip said, your missing the base URL
Your creating a whole new animation each time you press a button. Instead this is what you should do:
local uis = game:Get service("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait() -- this wait part should yield the code until the character exists.
local hum = char:WaitForChild("Humanoid")
local anim = Instance.new("Animation")
anim.AnimatonId = "rbxassetid://".."ANIMATION.ID.HERE"
local loaded_anim = hum:WaitForChild("Animator"):LoadAnimation(anim)
anim:Destroy() -- destroy the animation object because it is useless now
uis.InputBegan:Connect(function(key, proc)
anim:Play()
end)
This is just an example.
I wrote this on my phone. So, some of it may be off.