I am making a Survival game that includes hunger and thirst gui
here's the code for the hunger which works perfectly apart for the color change part
local HG = script.Parent
local num = HG:WaitForChild("Back"):WaitForChild("NumText")
local Text = HG:WaitForChild("Back"):WaitForChild("Text")
local Plr = game.Players.LocalPlayer
repeat wait() until Plr.Character
local Hum = Plr.Character:WaitForChild("Humanoid")
local MaxHunger = 100
local DecreaseRate = 25 -- 8 seconds = -1 hunger
local HungerValue = HG.HValue
HungerValue.Changed:connect(function()
Text:TweenSize(UDim2.new(HungerValue.Value/MaxHunger,0, 1,0), "Out", "Linear", .2, true)
end)
while wait(DecreaseRate) do
if HungerValue.Value - 1 >= 0 then
HungerValue.Value = HungerValue.Value - 1
end
HungerValue.Changed:connect(function()
num.Text = HungerValue.Value
end)
if HungerValue.Value == 0 then
repeat wait(1)
Hum.Health = Hum.Health - 2
until HungerValue.Value > 0 or Hum.Health <= 0
end
end
if HungerValue.Value < 41 then
Text.BackgroundColor = BrickColor.new("Daisy orange")
end
if HungerValue.Value < 21 then
Text.BackgroundColor = BrickColor.new("Persimmon")
end
if HungerValue.Value < 11 then
Text.BackgroundColor = BrickColor.new("Really red")
end
and here is the script of the thirst which is somehow defective
--First the variables
local Thirst = script.Parent
local Thirstval = Thirst.Value
local Back = Thirst:WaitForChild("Background")
local Tbar = Back:WaitForChild("Bar")
local Plr = game.Players.LocalPlayer
local hum = Plr.Character.Humanoid
local MaxThirst = 100
decreaserate = 30
local num = Thirst.Label
--wait till the character loads
repeat wait() until Plr.Character
while wait(decreaserate) do
if Thirstval.Value - 1 >= 0 then
Thirstval.Value = Thirstval.Value - 1 --reduce if it isnt 0 or below
end
Thirstval.Changed:connect(function()
num.Text = Thirstval.Value --update the text indicator
end)
if Thirstval.Value == 0 then
repeat wait(2.5)
hum.Health = hum.Health - 2.5 --reduce the health if its 0
until Thirstval.Value > 0 or hum.Health <= 0
end
end
Thirstval.Changed:connect(function()
Tbar:TweenSize(UDim2.new(Thirstval.Value/MaxThirst,0, 1,0),"Out","Linear", .2, true) --tween the bar indicators
end)
-- this is frustrating
I don't get why it isn't working, can someone pls tell me what I'm doing wrong?

3 comments
Please don't post in all 79 lines of code. Give us what you think are the problem parts of the code. The entire hunger code is irrelevant if we're focusing on your thirst code. You also need to tell us how the code is failing. Is it working up until the tweening? Is it just not working at all? More information like this would be helpful.
Ok thnx Im new to this website
and in line 11 i meant 15 secs