punch = false damage = true plr = game.Players.LocalPlayer while not plr.Character do wait() end plr:GetMouse().KeyDown:Connect(function(k) ctr = plr.Character hum = ctr:WaitForChild("Humanoid") LeftArm = ctr:WaitForChild("Left Arm") ctr = plr.Character PunchAnim = Instance.new("Animation") PunchAnim.AnimationId = "https://web.roblox.com/asset/?id=".."2523553984"--put id here PunchAnimTrack = hum:LoadAnimation(PunchAnim) Power = game.Players.LocalPlayer.PlayerGui.MenuGui.StatsFolder.StrengthValue.Value Strength = game.Players.LocalPlayer.PlayerGui.MenuGui.StatsFolder.Strength if k == "e" then if punch == false then punch = true damage = false PunchAnimTrack:Play() wait(0.5) punch = false damage = true end end end) while punch do LeftArm.Touched:Connect(function(hit) if damage == false then damage = true human = hit.Parent:WaitForChild("Humanoid") human:TakeDamage(Power) wait(0.5) damage = false end end) end
This is the script I used. Yes, I have tried printing and I don't seem to find the issue. No errors in output. The punching animation does work. If you know the answer to this, then tell me as soon as possible.
Replace line 8 with:
plr:GetMouse().Button1Down:Connect(function(k)
The reason why I'm saying this is because the Player's Mouse object does not have an event named KeyDown. KeyDown is a deprecated event and should not be used. Methods similar to KeyDown (i.e. IsKeyDown()) are meant for keyboards and not computer mice.
A similar solution involves using the UserInputService to get the mouse input. The UserInputService is actually BETTER than the Mouse class with the reason being that the Mouse class is about to be deprecated. If using the UserInputService, use the method IsMouseButtonDown(). That'll help you out quite a bit.