Hunger script/GUI problem

Hello,
I’m fairly new to LUA and Roblox Studio, currently I’m making a hunger and thirst scripts and whenever I try to test it in-game the GUI Bar just expands over the screen

----- Server side script
local decrease_frequency = 5
local decrease_amount = 2
local increase_amount = 8
game.Players.PlayerAdded:Connect(function(Player)
local Hunger = Instance.new(“IntValue”, Player)
Hunger.Name=“Hunger”
Hunger.Value=100

Player.CharacterAdded:Connect(function()
	Hunger.Value=100
end)
while wait (decrease_frequency) do
	if Hunger.Value <= 0 then
		Player.Character:BreakJoints()
	else
	
		Hunger.Value -= decrease_amount
	end
end

end)
game.ReplicatedStorage.Eat.OnServerEvent:Connect(function(Player)

Player.Hunger.Value += increase_amount 

end)

------- Client side script

local Player = game.Players.LocalPlayer
local Hunger = Player:WaitForChild(“Hunger”)
local GUI = script.Parent
local BarExterior = GUI.Bar
local function UpdateHunger()
local CurrentValue = Hunger.Value
local Formula = math.clamp(CurrentValue/100, 0, 1)

BarExterior:TweenSize(UDim2.new (Formula, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.2, true)

end
UpdateHunger()
Hunger.Changed:Connect(function()
UpdateHunger()
end)

------ In Roblox Studio
image

------ In the game

I really don’t know if this topic should be in Code Review since it’s technically working but the gui is messed up, and if i implement the script in another frame, the same thing happens.

Should I approach the code differently or is there a fix?

1 Like