So, I have this script that plays fighting animations; A punch and a kick. The only thing is I cant get it to do damage to npcs or other players. How would i make it so that i can set different damage values to different fighting moves? This is the script before it stopped working after trying to make it do damage

local animations = {
				[Enum.KeyCode.Q] = 1679481577,--When "Q" is pressed, a punch animation plays
				[Enum.KeyCode.E] = 1572108402,--When "E" is pressed, a kick animation plays
				--More fighting animations will be added later on
				
                   }

------------------------------------------------------------------------

repeat wait() until game.Players.LocalPlayer; local player = game.Players.LocalPlayer
repeat wait() until player.Character; local character = player.Character
local currentAnimId,currentPlaying = '',nil
local humanoid = character:FindFirstChild('Humanoid')
local uis = game:GetService('UserInputService')

uis.InputBegan:connect(function(input,gpe)
	if not gpe then
		if animations[input.KeyCode] ~= nil then
			local animId = 'http://www.roblox.com/Asset?ID=' .. animations[input.KeyCode]
			if animId ~= currentAnimId then
				if humanoid ~= nil and humanoid.Health > 0 then
					if currentPlaying ~= nil and currentPlaying.IsPlaying then
						currentPlaying:Stop()
					end
					local animation = Instance.new('Animation'); animation.AnimationId = animId
					local animTrack = humanoid:LoadAnimation(animation); currentPlaying = animTrack
					animTrack:Play(0.100000001,1,1)
				end
			end
		end
	end
end)

It would also be helpful if someone could explain to me how I would use "debounce" to stop players from spamming the moves.

2 comments

0

FE enabled or disabled?

0

Filtering enabled. I don't want people exploiting/ hacking the game to give themselves godly damaging power.