I am trying to play a kicking animation when the player hits a hitbox but the animation will not play and the function seems to be repeating multiple times. I haven’t been able to find the solution, here is my code:
local char = script.Parent
local hum = char:FindFirstChild("Humanoid")
local hitbox = game.Workspace.football.hitbox
local rs = game:GetService("ReplicatedStorage")
local re1 = rs:FindFirstChild("FireKickAnim")
local kickAnim = hitbox.KickAnim
local kickAnimTrack = hum:LoadAnimation(kickAnim)
hitbox.Touched:Connect(function(hit)
re1.OnClientEvent:Connect(function(shotpower)
if shotpower > 1 then
kickAnimTrack:Play()
print("done")
end
end)
end)
This code is placed inside a character and is a local script. It prints “done” approximately 100 times every test. If you can, please help. Thank you