While task.wait() loop not changing an IntValue in ServerStorage?

I have a very simple loop meant to decrease a value by 1 every second. The IntValue is present in a folder inside of ServerStorage, and the script is inside of the IntValue. However, for some reason, it just doesn’t work at all. No output errors, no weird outcomes, it just doesn’t do anything.
This is literally all there is to the code:

while task.wait(1) and script.Parent.Value > 0 do
	script.Parent.Value -= 1
end

I found similar posts and none of them had any working solutions. This is making no sense to me whatsoever and I’m honestly very baffled with the weird nature of this issue because I’m quite certain this should work, unless if it being in ServerStorage is a problem or if there is a silly problem I’m not catching here. I’m not even a beginner, I have no idea why this is happening whatsoever. I hope someone can help me out.

And yes, the script is enabled. No, nothing is changing the value from elsewhere. I did while task.wait() loops before and they used to work just fine.

It seems that nothing can change this value from that script for some reason. Even a simple “script.Parent.Value = 80” line doesn’t change it. What in the actual heaven is going on??

Are you sure the loop is actually going? Maybe the .Value is at 0 already possibly?

I’m not very sure if the loop is going, but I am using the run test to check if the value is changing on the server side and nothing seems to be changing there. I just tried telling it to print the value both outside and inside the loop and it doesn’t print anything out at all, which means that perhaps the script just isn’t working at all for some reason.

Where is this code located, a local script?

The code is located in a regular script inside of the IntValue instance, which is present inside of a folder in ServerStorage.

I managed to solve it in a strange way. Even though the script was not a LocalScript, which means it should have been working just fine on the server side, I managed to make it work by changing the RunContext to Server, which again, doesn’t make any sense since it’s not a LocalScript. It should have been working from the get go. Is this a bug?

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