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

Why doesn't my script damage players sometimes?

Asked by 5 years ago
Edited by M39a9am3R 5 years ago

This script damages any player that is hit by it, but if the player with the weapons stays still it instead passes through them without doing any damage...

01local modelstuff = {}
02function ontouch(hit)
03if hit.Parent:FindFirstChild("Humanoid") then
04local model = hit.Parent
05local hum = hit.Parent:FindFirstChild("Humanoid")
06        if modelstuff[model] then
07        return
08        else
09            local def = hit.Parent:FindFirstChild("Defense").Value
10            local dmg = script.Parent.Parent:WaitForChild("Attack").Value - def
11            hum:TakeDamage(dmg)
12            if hit.Parent:FindFirstChild("Bleed") then
13                if hit.Parent:FindFirstChild("Streak") then
14                    else
15                local streak = Instance.new("IntValue")
View all 44 lines...

Please help me, i cant script

0
You can't script? How did you make this? Trollapse 89 — 5y
0
I can't script well... Fl3eandFlo3e 18 — 5y
0
I remember having the same problem when making a gun. Idk how ur weapons work, so you should make a script that checks whether hit.Parent is a weapon EmbeddedHorror 299 — 5y
0
I don't get it, what do you mean? What would making a script that checks if hit.Parent is a weapon do? Fl3eandFlo3e 18 — 5y
View all comments (4 more)
0
models hit, the table of characters hit Fl3eandFlo3e 18 — 5y
0
oh ok. i thought you said a bad word 3wdo 198 — 5y
0
I went ahead and changed the variable name anyway since it did seem like vulgar words. Might I suggest using camel case in the future? M39a9am3R 3210 — 5y
0
Ok, yea sorry i should've changed it Fl3eandFlo3e 18 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

it's because it only triggers when it's "TOUCHED" not when it's in that part

if you want to make it so if it's in the player part it still damages while not moving probably either use "FindPartsInRegion3" or a few scripts that check if parts left or go into a part and add that to the list THEN damage all the players in there with another script

Ad

Answer this question