Make my script only deal damage when keycode C is clicked?
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
02 | local lleg = script.Parent:FindFirstChild( "Left Leg" ) |
03 | local rleg = script.Parent:FindFirstChild( "Right Leg" ) |
05 | local UIS = game:GetService( "UserInputService" ) |
06 | local character = script.Parent |
07 | local humanoid = character:WaitForChild( "Humanoid" ) |
08 | local DropAnim = Instance.new( "Animation" ) |
12 | local CanDropkick = false |
13 | local Keybind = Enum.KeyCode.E |
14 | local LeftLeg = game.Players.LocalPlayer.Character [ "Left Leg" ] |
15 | local RightLeg = game.Players.LocalPlayer.Character [ "Right Leg" ] |
18 | character.Humanoid.Running:Connect( function (speed) |
19 | if speed > topspeed then |
22 | else if speed < topspeed then |
32 | if hit.Parent ~ = nil then |
33 | local hum = hit.Parent:findFirstChild( "Humanoid" ) |
35 | hum.Health = hum.Health - 10 |
40 | lleg.Touched:connect(dmg) |
41 | rleg.Touched:connect(dmg) |
43 | UIS.InputBegan:Connect( function (input,gameprocessed) |
44 | if gameprocessed then return end |
45 | if not CanDropkick then return end |
46 | if not dmg then return end |
47 | if input.KeyCode = = Keybind then |
55 | local playAnim = character.Humanoid:LoadAnimation(DropAnim) |
58 | local drop = Instance.new( "BodyVelocity" ) |
59 | drop.MaxForce = Vector 3. new ( 1 , 0 , 1 ) * 30000 |
60 | drop.Velocity = character.HumanoidRootPart.CFrame.lookVector * 85 |
61 | drop.Parent = character.HumanoidRootPart |