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

How to make a button slowly kill a player? (More info in desc.)

Asked by
Skyyrn 1
3 years ago

I want to make a button slowly kill a player, but when they exit a radius, they will stop taking damage. Here is the code that I'm using to get a button to slowly kill a player:

clickDetector.MouseClick:Connect(function()
        local h = hit.Parent:findFirstChild("Humanoid")
        while true do
            if (h ~= nil) then
                h.Health = h.Health - 2
                wait(1)
            end
        end
    end)

But I still need to find a way on how to make it so that it stops after the player leaves a certain radius. What functions and services (and such) would I use?

0
on a mouse click. it goes player and then character. so you would do local h = plr.Character:findFirstChild('Humanoid') In the parameters you would put plr malachiRashee 24 — 3y
0
If you got the health decreasing and whatnot and just asking for the radius then I would suggest either using magnitude which can be difficult to use at times or use some other thing Rayguyban2 89 — 3y

1 answer

Log in to vote
0
Answered by
A_Mp5 222 Moderation Voter
3 years ago

if im getting you right, this is what you want?

    clickDetector.MouseClick:Connect(function()
local healthrange = --what health you want them to end up with
            local h = hit.Parent:findFirstChild("Humanoid")
            repeat
                if (h ~= nil) then
                    h.Health = h.Health - 2
                    wait(1)
                until h.Health == healthrange
            end
        end)
Ad

Answer this question