Script keeps printing almost the same number

Why does it keep printing 49, even though it should decrease by 1 every second? Why is this happening? :pensive:
it’s a loca script:

local SurvivalNeeds = {
	WaterSurvival = 50,
	SleepSurvival = 50,
	ToiletSurvival = 50,
	FoodSurvival = 50
}

while wait(1) do

	if player.Character  then
		for index, value in SurvivalNeeds do
			for _, needsframe in SurviveFrame:GetChildren() do
				if needsframe:IsA("ImageLabel") and needsframe.Name == index then

					value = value - 1

					print(value)
				end

			end
		end

	end

end
1 Like

I think you are forgetting to update it in the dictionary.

1 Like

Change it to this:

while wait(1) do

	if player.Character  then
		for index, value in SurvivalNeeds do
			for _, needsframe in SurviveFrame:GetChildren() do
				if needsframe:IsA("ImageLabel") and needsframe.Name == index then

					value = value - 1
					SurvivalNeeds[index] = value -- Update the value in the table
					print(value)
				end

			end
		end

	end

end
2 Likes

Good,that was the solution to your problem.

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