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"

01hs.Touched:connect(function(dmg) -- if you touch this
02            hss.Touched:connect(function(dmg)-- or this it does 10 damage but it no do that :c
03            if dmg.Parent:FindFirstChild("Humanoid")~= nil then
04    if dmg.Parent.Name ~= plr.Name then
05    dmg.Parent.Humanoid:TakeDamage(10)
06        hs:Remove()
07                hss:Remove()
08    end
09end
10        end)
11        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:

1Baseplate = 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:

01hs.Touched:connect(function(dmg) -- if you touch this
02    if dmg.Parent:FindFirstChild("Humanoid")~= nil then
03        dmg.Parent.Humanoid:TakeDamage(10)
04        hs:Remove()
05        hss:Remove()
06    end
07end)
08hss.Touched:connect(function(dmg)
09    if dmg.Parent:FindFirstChild("Humanoid")~= nil then
10        dmg.Parent.Humanoid:TakeDamage(10)
11        hs:Remove()
12        hss:Remove()
13    end
14end)

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