How can I update position while a tween is running + How can I loop this tween

I’ve been trying all solutions the whole day and i can’t figure it out how to update the hunger bar position while a tween is running and How to loop this tween.

I have another script but that’s a tool that if you eat food, it will set the value to 0, it did set the value of “HungerValue” but not of the position so it keeps running.

If you need more information, tell me some questions, i will respond to them!
Thank you for reading and trying to find a solution.

script.Parent:TweenPosition(UDim2.new(1, 0, 0, 0),
	Enum.EasingDirection.In, 
	Enum.EasingStyle.Linear,   
	60,                       
	true                   
)

while wait() do -- Update the pos value
	local pos = script.Parent.Position.X.Scale
	local value = script.Parent.HungerValue.Value
	pos = value
	value = pos
	if pos == 1 then
		local h = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
		if h then
			h.Health = 0 -- If the hunger bar is empty, the player dies
		end
	end
end
1 Like

to loop it, add these three arguments into the the TweenInfo, after the current ones you already have. separate them with commas except for the last one.

0, 
false,
-1

add a comma after the “true” that is in the info and add these. As for updating, use a while wait(.1) do
to update it

1 Like

I got an error saying: “Unable to cast value to function”
I made everything that you told me to do, here’s the tweenInfo

TweenInfo
Enum.EasingDirection.In,
Enum.EasingStyle.Linear,
60,
true,
0,
false,
-1