Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Make the players legs deal damage when the keycode C is pressed?

Asked by 1 year ago

Hi, what i want to happen is so that the players legs deal damage (when you click C) when they touch another player but my problem is that the legs constantly deal damage, 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)

0
there's a problem with ur debounce ZeroToH3ro 82 — 1y
0
i dont have debounce because i dont know how to implement it 123marooxd123 13 — 1y

Answer this question