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

Make my script only deal damage when keycode C is clicked?

Asked by 2 years ago

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

01--Made By 123Marooxd123
02local lleg = script.Parent:FindFirstChild("Left Leg")
03local rleg = script.Parent:FindFirstChild("Right Leg")
04 
05local UIS = game:GetService("UserInputService")
06local character = script.Parent
07local humanoid = character:WaitForChild("Humanoid")
08local DropAnim= Instance.new("Animation")
09DropAnim.AnimationId = "rbxassetid://9642052968"
10 
11local dmg = false
12local CanDropkick = false
13local Keybind = Enum.KeyCode.E
14local LeftLeg = game.Players.LocalPlayer.Character["Left Leg"]
15local RightLeg = game.Players.LocalPlayer.Character["Right Leg"]
View all 73 lines...

1 answer

Log in to vote
0
Answered by 2 years ago
1function dmg(hit) --- this is the function that lets the player deal damage with their legs
2if not CanDropkick then return end
3    if hit.Parent ~= nil then
4        local hum = hit.Parent:findFirstChild("Humanoid")
5        if hum ~= nil then
6            hum.Health = hum.Health -10
7        end
8    end
9end
Ad

Answer this question