Need some help with my hunger bar



So i need some help with this bit of code, i want it to reduce itself whenever a int value from my data store is deducted but instead of getting smaller, its getting bigger downwards its a bit weird

local Player = game.Players.LocalPlayer
wait(2)

script.Parent.Size = UDim2.new(Player.PlayerData.Hunger.Value/100, 0,1,0)

Player.PlayerData.Hunger.changed:Connect(function(newh)
	script.Parent.Size = UDim2.new(Player.PlayerData.Hunger.Value/100, 0,1,0)
end)

Try this, I would advise using TweenService for this:

local Player = game.Players.LocalPlayer

local TS = game:GetService("TweenService")

script.Parent.Size = UDim2.new(Player.PlayerData.Hunger.Value/100, 0, 1, 0)

Player.PlayerData.Hunger.Changed:Connect(function()
    local goal = UDim2.new(--int value of the lowest bar level that you want their hunger to go to)
    local TI = TweenInfo.new(NUMBER OF HOW LONG YOU WANT IT TO WAIT BEFORE GOING DOWN, Enum.EasingStyle.Linear)
    TS:Create(script.Parent, TI, goal)

    TS:Play
end)

Cheers mate it worked, the problem i had was that i didn’t have a base frame for it to lead on. thats on me for being too tired to realise

1 Like