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

How do I make the LeftPunch function do damage?

Asked by 10 years ago

I am trying to make the LeftPunch function do damage. But I can't figure it out. I would love it if someone helped me!

Player = game.Players.LocalPlayer
Character = Player.Character
Mouse = Player:GetMouse()

LeftShoulder = Character.Torso["Left Shoulder"]
RightShoulder = Character.Torso["Right Shoulder"]
LeftHip = Character.Torso["Left Hip"]
RightHip = Character.Torso["Right Hip"]

function LeftPunch(key)
    Key = key:lower()
    if Key == "q" then
        for i = 1, 1 do
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, -0.25)
                wait()
            end
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, 0.25)
                wait()
            end
        end
    end 
end

function RightPunch()

end

function LeftKick()

end

function RightKick()

end

Mouse.KeyDown:connect(LeftPunch)

1 answer

Log in to vote
1
Answered by 10 years ago

With the arm, you could connect the Touched event to the arm.

To enforce the damage, we could employ the TakeDamage function of a Humanoid. The code would end up looking something like (with your current code):

local arm = Character['Left Arm'];
arm.Touched:connect(function(hit)
if not(hit.Parent:FindFirstChild'Humanoid') then return end;
hit.Parent.Humanoid:TakeDamage(13);
end);

Also, if you want to have the damage stored at the top in a variable, you could do that.

Ad

Answer this question