(Solved) Thirst bar going over the max

local Puddle = script.Parent
local Regen = 0.1

Puddle.ProximityPrompt.Triggered:Connect(function(Player)
	local ThirstBar = Player.PlayerGui.Thirstbar.Bar
	ThirstBar.Size += UDim2.new(Regen, 0, 0, 0)
	Puddle.ProximityPrompt.Enabled = false
	Puddle.Transparency = 1	
	if ThirstBar.Size.X.Scale >= 0.302 then
		ThirstBar.Size.X.Scale = UDim2.new(0.302, 0, 0.087, 0) -- this code is MEANT to make it so it can't go over max but it uh it's not please help
	end
end)
wait(30)
Puddle.Transparency = 0.1
Puddle.ProximityPrompt.Enabled = true
3 Likes

Perhaps clamping the number can help you with your issue, like this:

ThirstBar.Size = UDim2.new(math.clamp(ThirstBar.Size.X.Scale + Regen, 0, 0.302), 0, 1, 0, 0, 0)

Let me know if you still experience the same issue or if you have any questions

4 Likes

I have no idea what this means Iā€™m just trying to get voice chat

Sadly the same issue still persists, lmk if you have anymore ideas, Thanks!

Wait it was something i was doing wrong, I have it working now. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.