Any way to make an air tank system?

I wanted to ask is there a way to make a gui change its text when a zone is entered and when it is left?
( i have heard of zone+) i just want to know if there is any other way of doing it.
By the way, should i change the text label to somthing else because i want to use -1
My text right now looks like this
Screenshot 2024-05-18 235329

The “100 / 100” is only one whole text label making me believe that using something like -1 would not work as well

If your lost of what im trying to say, please read this.
Simply, when the player enteres the presence of a part (cancollide off) The number will begin to count down until the player leaves the part. When the count down reaches 0, for the next 15 seconds they will rapidly begin to lose health

Thanks, ill answer any questions.

Not sure if this would work, but you could try using the .Touched and .TouchEnded events and holding an array of players that are currently in the part. Then, you can use a remote to communicate to the client when to and when not to update the text on their label.

1 Like

Instead of using the .Touched event you should use workspace:FindPartsInRegion3() and extract the players that way, it’s a lot more efficient!

Didn’t know that existed, thanks for the correction!

local entered = false

local waterZones = workspace.WaterZones

for i,v in ipairs(waterZones:GetChildren(() do
    v.Touched:Connect(function(hit)
        entered = true
    end)

    v.TouchEnded:Connect(function(hit)
        entered = false
    end)
end

Could you give me a short walkthrough of what i could do?

Assuming the code works, you could do a while loop using the “entered” variable, as so:

local air = 100

while entered do
local air =- 1
TextLabel.Text = tostring(air..” / 100”).
wait(1)
end

You could then do another while loop in reverse (using the not keyword) and adding 1 air instead of subtracting to get the effect of regenerating air.

But do keep in mind though, this is a very simple implementation.