Hello! Im trying to make a dropkick script, ive already got everything set except i encountered one major problem. My intention was to have the player deal damage to an enemy when they click the keycode C but the players legs constantly deal damage, i dont know what to do please help
--Made By 123Marooxd123 local lleg = script.Parent:FindFirstChild("Left Leg") local rleg = script.Parent:FindFirstChild("Right Leg") local UIS = game:GetService("UserInputService") local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local DropAnim= Instance.new("Animation") DropAnim.AnimationId = "rbxassetid://9642052968" local dmg = false local CanDropkick = false local Keybind = Enum.KeyCode.E local LeftLeg = game.Players.LocalPlayer.Character["Left Leg"] local RightLeg = game.Players.LocalPlayer.Character["Right Leg"] local topspeed = 25 character.Humanoid.Running:Connect(function(speed) if speed > topspeed then CanDropkick = true dmg = true else if speed < topspeed then CanDropkick = false dmg = false end end end) function dmg(hit) --- this is the function that lets the player deal damage with their legs if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end lleg.Touched:connect(dmg) rleg.Touched:connect(dmg) UIS.InputBegan:Connect(function(input,gameprocessed) if gameprocessed then return end if not CanDropkick then return end if not dmg then return end if input.KeyCode == Keybind then CanDropkick = false dmg = false local playAnim = character.Humanoid:LoadAnimation(DropAnim) playAnim:Play() local drop = Instance.new("BodyVelocity") drop.MaxForce = Vector3.new (1,0,1) *30000 drop.Velocity = character.HumanoidRootPart.CFrame.lookVector * 85 drop.Parent = character.HumanoidRootPart for count = 1, 8 do wait(0.13) drop.Velocity*= 0.5 end playAnim:Stop() drop:Destroy() CanDropkick = true dmg = true end end)
function dmg(hit) --- this is the function that lets the player deal damage with their legs if not CanDropkick then return end if hit.Parent ~= nil then local hum = hit.Parent:findFirstChild("Humanoid") if hum ~= nil then hum.Health = hum.Health -10 end end end