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

Why isn't this doing damage when it touches one of these parts?

Asked by 8 years ago

It's supposed to do damage when an enemy touches"hs" or "hss"

hs.Touched:connect(function(dmg) -- if you touch this
            hss.Touched:connect(function(dmg)-- or this it does 10 damage but it no do that :c
            if dmg.Parent:FindFirstChild("Humanoid")~= nil then
    if dmg.Parent.Name ~= plr.Name then
    dmg.Parent.Humanoid:TakeDamage(10)
        hs:Remove()
                hss:Remove()
    end
end
        end)
        end)
0
Please read your code User#6546 35 — 8y
0
LOL evaera 8028 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

You need to define hs and hss. That is also called making a variable

Example:

Baseplate = game.Workspace.Baseplate 

For more info on variable visit

http://wiki.roblox.com/index.php?title=Variable

0
I did that.......that was the first thing I did. coolg5555 70 — 8y
0
Thats not what it shows... You just put it into an event JoshWplaysRoblox 10 — 8y
0
Thats part of the full script. This is the damage part I do this so people can't copy my scripts. coolg5555 70 — 8y
0
How can we help you, if you don't show us the full script. JoshWplaysRoblox 10 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Well, assuming that all the variables are not nil (are defined) then this should work perfectly fine. I'm not 100% sure why your original script did not work, but I have an idea. Oh well, try this:

hs.Touched:connect(function(dmg) -- if you touch this
    if dmg.Parent:FindFirstChild("Humanoid")~= nil then
        dmg.Parent.Humanoid:TakeDamage(10)
        hs:Remove()
        hss:Remove()
    end
end)
hss.Touched:connect(function(dmg)
    if dmg.Parent:FindFirstChild("Humanoid")~= nil then
        dmg.Parent.Humanoid:TakeDamage(10)
        hs:Remove()
        hss:Remove()
    end
end)

Oh and please, could you use code indentation next time for making it easier for people to read your script (I hope this doesn't sound like I'm acting aggressive towards you)? Thank you.

Answer this question