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

I don't understand the hit code, when a player kicks another player?

Asked by 10 years ago

How does it damage the other player? I don't understand... Could someone tell me how to use it??

0
Can you explain what you mean? What hit code? systematicaddict 295 — 10y
0
Like, the way to takedamage... TheReapersComing 0 — 10y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Well, that's basically the Touched event. You would have it so it leads to their leg. The TakeDamage method could be used if you don't want to subtract theirs by a certain number. TakeDamage ONLY works if their is no forcefield is present, so that's pretty good so no spawn killing. Let me give you can example..

--Local script
plr = game.Players.LocalPlayer
char = plr.Character

function debounce(func)
    local isRunning = false
    return function(...)
        if not isRunning then
            isRunning = true
            func(...)
            isRunning = false
        end
    end
end


char["Right leg"].Touched:connect(debounce(function(hit) -- Not sure if it's 'Right leg'. You may want to check.
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
        victim = game.Players:GetPlayerFromCharacter(hit.Parent)
        victim.Character.Humanoid:TakeDamage(15) -- Amount they are affected by
    end
end))

The only reason this may not be as good as a tool because two people could run into each other and they'd both die. With a tool, it's sort of like Sword Fighting, except with your legs.

0
Is there a pushback effect?? How would you do that as well? TheReapersComing 0 — 10y
0
Well you'd need to make that. It's not an event. That 'effect' is just looping the Cframe a couple of times. Need an example? Shawnyg 4330 — 10y
Ad

Answer this question