My problem is after the animation is done it can no longer do damage but it still does damage:
plr = game.Players.LocalPlayer Kick = script:WaitForChild("KickAnimation") Punch = script:WaitForChild("PunchAnimation") mouse = plr:GetMouse() RightArm = plr.Character:WaitForChild("Right Arm") RightLeg = plr.Character:WaitForChild("Right Leg") True = true --> Punch Animation Script mouse.KeyDown:connect(function(key) if key == "q" then if not True then return end True = false local aTrack = plr.Character.Humanoid:LoadAnimation(Punch) aTrack:Play() wait(2) True = true RightArm.Touched:connect(function(hit) local ehum = hit.Parent:FindFirstChild("Humanoid") if ehum and ehum ~= plr.Character.Humanoid then ehum:TakeDamage(10) return hit end end) end end)
Your problem is here
RightArm.Touched:connect(function(hit) local ehum = hit.Parent:FindFirstChild("Humanoid") if ehum and ehum ~= plr.Character.Humanoid then ehum:TakeDamage(10) return hit end end)
The thing about events is that, when connected, they continue to work until the event is disconnected (using :disconnect()), the object that the event is child of (Ex. Right Arm) gets destroyed, or the script that the event is connected (this script) gets destroyed.
Also, do not use :connect() because it's old, use :Connect().
What you want to do, is to disconnect the Touched event.
First, we need to assign this event to a variable.
local touchedEvent = RightArm.Touched:Connect(function(hit) local ehum = hit.Parent:FindFirstChild("Humanoid") if ehum and ehum ~= plr.Character.Humanoid then ehum:TakeDamage(10) return hit end end)
Then after some time, disconnect the event.
touchedEvent:Disconnect()
After that, this script will no longer listen to the touched event.
plr = game.Players.LocalPlayer Kick = script:WaitForChild("KickAnimation") Punch = script:WaitForChild("PunchAnimation") mouse = plr:GetMouse() RightArm = plr.Character:WaitForChild("Right Arm") RightLeg = plr.Character:WaitForChild("Right Leg") True = true --> Punch Animation Script mouse.KeyDown:connect(function(key) if key == "q" then if not True then return end True = false local aTrack = plr.Character.Humanoid:LoadAnimation(Punch) aTrack:Play() local touchedEvent = RightArm.Touched:Connect(function(hit) local ehum = hit.Parent:FindFirstChild("Humanoid") if ehum and ehum ~= plr.Character.Humanoid then ehum:TakeDamage(10) return hit end end) wait(2) True = true touchedEvent:Disconnect() end end)