local player = game.Players.LocalPlayer local mouse = player:GetMouse() local Combo = 1 local enabled = true local CanDamage = false mouse.KeyDown:connect(function(key) if key == "q" then if Combo == 1 then if not enabled then return end enabled = false local a = player.Character.Humanoid:LoadAnimation(script.Punch1):Play() wait(0.5) Combo = 2 enabled = true mouse.KeyDown:connect(function(key) if key == "q" then if Combo == 2 then if not enabled then return end enabled = false local b = player.Character.Humanoid:LoadAnimation(script.Punch2):Play() wait(0.5) Combo = 3 enabled = true mouse.KeyDown:connect(function(key) if key == "q" then if Combo == 3 then if not enabled then return end enabled = false local c = player.Character.Humanoid:LoadAnimation(script.Kick):Play() wait(0.5) Combo = 1 enabled = true end game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)['LeftHand'].Touched:connect(function(part) local human= part.Parent:findFirstChild("Humanoid") if human then if human.Parent.Name~= game.Players.LocalPlayer.Name and CanDamage == false then CanDamage = true human:TakeDamage(10) wait(1.2) CanDamage = false end end end) game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)['RightHand'].Touched:connect(function(part) local human= part.Parent:findFirstChild("Humanoid") if human then if human.Parent.Name~= game.Players.LocalPlayer.Name and CanDamage == false then CanDamage = true human:TakeDamage(10) wait(1.2) CanDamage=false end end end) end end) end end end) end end end)
Basically I tried to change the CanDamage Variable to false instead of true i switched places between them and nothing seems to work It does damage even when the animation is not playing.
Help me please.
First of all using Mouse to use keyboard is limited use and also deprecated its a bad practice to use it, i suggest start using "UserIputService" which you will have more control on your input.
API http://wiki.roblox.com/index.php?title=API:Class/UserInputService
How to use one http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan
Example:
This example must be inside of your player or character and must be localscript or else wont work.
this will work also inside of the tool because since tool is equipped then tool is transferred to the player character since localscript is inside the tool. got it?
---LOCALSCRIPT
local player = game.Players.LocalPlayer -- This will only work on local script, on normal script it is not local UIS = game:GetSerivce("UserInputService") local Anim = player.Character.Humanoid:LoadAnimation(script.Punch1) local Anim2 = player.Character.Humanoid:LoadAnimation(script.Punch2) Combo = 1 CanDamage = false UIS.InputBegan:connect(function(key, gameproc) if not gameproc and key.KeyCode == Enum.KeyCode.Q and Combo == 1 then CanDamage = true Combo = 2 Anim:Play() local lefthand = player.Character:FindFirstChild("LeftHand") lefthand.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and CanDamage == true then hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10) end wait(0.1) CanDamage = false elseif not gameproc and key.KeyCode == Enum.KeyCode.Q and Combo == 2 then CanDamage = true Combo = 3 Anim2:Play() local lefthand = player.Character:FindFirstChild("LeftHand") lefthand.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and CanDamage == true then hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10) end wait(0.1) CanDamage = false ---- and Continue it end end)
Gameproc or GameProcessed needs to be check false so while in the middle of typing in chat the input or key you set is pressed wont activate it. so it will not be annoying sometimes.
Press answer if this helps you! ~~Neuroticxs