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

Creating poison gas?

Asked by
saenae 318 Moderation Voter
9 years ago

So, I've been attempting to create a poison gas object, and the only problem I've faced thus far is damaging others. Using .Touched, whenever the person being effected stops moving, they're not damaged. Using magnitude, I lag half to death. Any ideas? Thanks as usual! :)

0
I came up with a runaround, for those who are interested. Basically, I just put those who touched the object into a table, and then put in a loop that took said person's magnitude. If they went out of the distance, they stopped getting damaged, whereas if they went back and touched the object, they got damaged again. saenae 318 — 9y
0
Lol, I crashed my studio trying to help xAtom_ik 574 — 9y
0
Haha, I know the feel. Thanks for the effort! saenae 318 — 9y

1 answer

Log in to vote
1
Answered by
drew1017 330 Moderation Voter
9 years ago

There's an event called TouchEnded that does exactly what you think it does. You can combine it with Touched so that they constantly take damage while touching the cloud. Something like this:

touching = false

function damage(hit)
    if hit:FindFirstChild('Humanoid') then
        player = hit
        touching = true
        while touching do
            hit.Humanoid:TakeDamage(1)
            wait(.1)
        end
    end 
end

function stoptouch(stopped)
    if stopped == player then
        touching = false
    end
end
0
I hadn't known about .TouchEnded, that'll be really helpful now and later. Thanks so much! ^^ saenae 318 — 9y
Ad

Answer this question