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 4 years ago
Edited by M39a9am3R 4 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...

local modelstuff = {}
function ontouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local model = hit.Parent
local hum = hit.Parent:FindFirstChild("Humanoid")
        if modelstuff[model] then
        return
        else
            local def = hit.Parent:FindFirstChild("Defense").Value
            local dmg = script.Parent.Parent:WaitForChild("Attack").Value - def
            hum:TakeDamage(dmg)
            if hit.Parent:FindFirstChild("Bleed") then
                if hit.Parent:FindFirstChild("Streak") then
                    else
                local streak = Instance.new("IntValue")
                streak.Parent = hit.Parent
                streak.Name = "Streak"
                end
                local st = hit.Parent:FindFirstChild("Streak")
                st.Value = st.Value + 1
                hit.Parent:FindFirstChild("Bleed").Dmg.Value = hit.Parent:FindFirstChild("Bleed").Dmg.Value + 1
                hit.Parent:FindFirstChild("Bleed").Time.Value = hit.Parent:FindFirstChild("Bleed").Time.Value + 1
                local bled = hit.Parent:FindFirstChild("Head").Bleed
                bled.TextLabel.Text = "Bleed X".. st.Value
            else
                local bleed = game.ServerStorage.Effects.Bleed:Clone()
                bleed.Disabled = false
                bleed.Parent = hit.Parent
            end
            local h = hit.Parent:FindFirstChild("HumanoidRootPart")
            local bb = game.ServerStorage.Classes.BillboardGui:Clone()
            bb.Parent = h
            local txtlabel = bb:WaitForChild("TextBox")
            if dmg > 20 then
                txtlabel.TextColor3 = Color3.fromRGB(255,0,0)
            end
            txtlabel.Text = tostring(dmg)
        end
        modelstuff[model] = true
        wait(.5)
        modelstuff[model] = false
end
end
script.Parent.DmgBox.Touched:Connect(ontouch)

Please help me, i cant script

0
You can't script? How did you make this? Trollapse 89 — 4y
0
I can't script well... Fl3eandFlo3e 18 — 4y
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 — 4y
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 — 4y
View all comments (4 more)
0
models hit, the table of characters hit Fl3eandFlo3e 18 — 4y
0
oh ok. i thought you said a bad word 3wdo 198 — 4y
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 — 4y
0
Ok, yea sorry i should've changed it Fl3eandFlo3e 18 — 4y

1 answer

Log in to vote
0
Answered by 4 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