Everything works, except once the tool is activated, the right hand is constantly doing damage and doing knockback, any way to fix this? This is in localscript inside a tool
local player = game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
mouse = player:GetMouse()
local hum = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
local tool = script.Parent
debounce = false
tool = script.Parent --you hadnt set this to anything
hum = game:GetService("Players").LocalPlayer.Character.Humanoid -- you hadnt set this either
--local anims = {script.Animation1,script.Animation2}--stores the animations in an array
local anims = {
script.Animation1;
script.Animation1;
}
-- the chosen attack was the first in the array anims
-- that means that the animation chosen was script.Animation1
-- gets a random number from 1 to 2
tool.Activated:Connect(function()
if not debounce then -- if debounce is false
debounce = true --sets it to true
local attack = math.random(2);
local animation = hum:LoadAnimation(anims[attack]);
animation:Play();
if(attack == 1)then
plr.Character.RightHand.Touched:connect(function(part)
local rhOn = false
if not rhOn then
rhOn = true
local D = plr.leaderstats.Strength
local Dmg = D.Value / 4
wait(0.5)
if part.Parent:findFirstChild("Humanoid") then
local hum = part.Parent.Humanoid
hum:TakeDamage(Dmg)
end
--Knockback
local check = part.Parent:FindFirstChild("Humanoid")
if check and part.Parent.Name ~= player.Name then
local knock = Instance.new("BodyVelocity")
check.Jump = true
knock.Parent = part.Parent.Torso
knock.maxForce = Vector3.new(math.huge,math.huge,math.huge)
knock.velocity = player.Character.Head.CFrame.lookVector*90
wait(0.2)
knock:Destroy()
end
----
wait(2)
rhOn = false
end
end)
end
wait(2)--waits 1
debounce = false--sets debounce to fals
end
end)

2 comments
what do i enter in the "attacking ="? true and false? or just leave it
the bolded values were taken out. thats what happened..