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

How would I make a brick that hurts you ONLY if you're inside it and if you're moving?

Asked by 5 years ago

I'm trying to experiment around with different kinds of damaging bricks, but I don't know how to make the script detect if the player is outside of the brick, thus the script will keep doing the code that runs to attempt to detect player movement, both inside and outside.

Script inside brick:

script.Parent.Touched:Connect(function(hit)
    local hum = hit.Parent:WaitForChild("Humanoid")
    hum.Running:Connect(function(spd)
        if spd == 0 then
            print("no damage")
        else
            print("damage")
        end
    end)
end)
0
try using the humanoid.StateChanged(oldstate,newstate) event theking48989987 2147 — 5y
0
i don't think that'll work, because i want the script to NOT damage the player when they're far from the brick, and the moment the player begins to run the damage will take effect. MeleeSoul 14 — 5y
0
What do you mean by "inside"? that it doesn't have Collide ON? DevSersponge 5 — 5y
0
wouldnt you just need to test if the player is "touching" the brick? if they arnt touching it then they are outside of it.... Right? joeldes 201 — 5y
View all comments (2 more)
0
and by inside, yeah, i mean it doesnt have collide on. MeleeSoul 14 — 5y
0
and the thing is, at the moment, if the player touches the brick atleast ONCE, the effects of the script will keep running, joel MeleeSoul 14 — 5y

Answer this question