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

How does hurting a humanoid work?

Asked by 7 years ago

So basically, I'm completely lost when it's come to damaging another humanoid, this time I plan to make it so it damages a player when the animation plays, but the problem is the animation is a right punch, and I don't know how to make that one limb damage another person, this is what I got.

mouse.KeyDown:connect(function(onKeyDown)
if not debounce and key == "e" and AnimSet.Value == true then
    brawlerright:Play()
    debounce = true
    wait(1)
    debounce = false
end

It's a bigger script with variables and such, but I'm only showing the part which is where the animation plays. I know this might be a request and I've looked for hours on the wiki and on youtube about this matter, but I just don't get it.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

you need to add an on touched function to the character that is using the animation. so lets say that this script is located in the players character, where it should be. Use this for referance, not sure where your function would need to be located in your script. Just so you know i think that no requests rule is a load of trash. if new scripters feel like they have no place to turn to and the one site called "Scripting Helpers" turns them away, or moderates their question off the website entirely, then this website shouldnt even EXIST. it completely defeats the purpose of the website and goes against the name. This should be a website scripters of all levels of experience can turn to, not just the ones that already know what theyre doing. It begs the question, Whats the point? if you have any more questions and one of the moderators deletes your question, message me on roblox and ill help all i can.

local alreadyhit = false

mouse.KeyDown:connect(function(onKeyDown)
if not debounce and key == "e" and AnimSet.Value == true then
    brawlerright:Play()
    debounce = true
    wait(1)
    debounce = false
end)


function onTouch (hit)

if hit.Parent.Humanoid ~= nil then

    if alreadyhit == false then

    hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 15 -- edit this for damage
    alreadyhit = true
    wait(1)
    alreadyhit = false
end



script.Parent["Left Arm"].Touched:connect(onTouch)


0
Use "and"s SH_Helper 61 — 7y
0
using if statements is much more reliable for my experience, so no ace12345678135 50 — 7y
Ad

Answer this question