I have a IntValue which waits 10 seconds, and this scripts basically counts from 10 to 0, I believe the IntValue runs faster when the game is ran, and the scripts gets a delay by some seconds making it stop before the IntValue is done waiting 10 seconds?
That was also my initial thought, which is why I was going to suggest you to play with the wait() function. However, it doesn’t make sense that the client/server runtime or speed would affect how many times a for loop will loop. Thus I figured that wouldn’t play any part in what numbers are printed in the console.
But then again, you might as well try it out? Let me know how changing that part goes.
I actually have did some changes to the wait, but changing that makes the count faster. Although let me check 1 more time!
Hello there!
At first glance here, I see no source of error. Through further investigation and testing, the code works flawlessly in my own studio application.
I have reason to believe this is not the whole script you’re giving us, I just want confirmation that it is the whole script you’re giving us. As I see no discrepancies which could be giving you this type of error.
Once this question is answered, I can proceed in helping you troubleshoot.
Thanks! <3
Why don’t you use repeat until?
Instead of for i = do repeat until Its what I use I’m not forcing you to just saying
For loops like the one given above are far more accurate and useful for the type of thing he wants, which is a timer.
Its just easier to do though
Here is a example
local t = 20
repeat
t = t - 1
wait(1)
print(t)
until t == 0
How it works is that once I click a button, a map gets cloned into workspace which has my script inside and the IntValue. Everything works, the intvalue waits 10 seconds but the GUI counts until 2 and nothing happens.
Add a print() and see if it gets printed
Tbh I never really understood how repeat until
& for do
loops worked, but personally I just use for do
more cause they’re more easier & simpler to understand
Otherwise, it’d make no difference regardless & it’d make the script a bit more complicated than what it needs to be
Just using repeat is simple and I use it for my minigame script for a rising lava if you want to know where my topic on my rising lava is here: Feedback on my rising lava
See, a chunk of code like so is far more complicated than a simple timer needs to be. The for
loop lets you run a command or group of commands a set number of times.
You can read more here.
If I may ask, what chunk of code changes the GUI Label?
I’m just use to it and it works very well just why is it for checking or something
I think if you provided nino (or the post in general) with more complete code from your script and the portions related to the code, then it would help us help you. I agree with nino, as “At first glance here, I see no source of error.”
Wish you the best of luck!
Its a while true do that does it or he can use the .changed event but for some reason it wasn’t working for me before so I used while true do
This is what’s in the GUI if that’s what you’re asking for:
This just changes the Text.
local status = game.ReplicatedStorage:WaitForChild("Status")
script.Parent.Text = status.Value
status.Changed:Connect(function()
script.Parent.Text = status.Value
end)
And as I mentioned, after I click the button, maps gets cloned into workspace which has a intvalue inside & a script. The script is then set to wait along with the intvalue to 10 seconds, but it stops at 2, while the Intvalue is done waiting for 10 seconds.
local Status = game.ReplicatedStorage:WaitForChild("Status")
for i = 10,0, -1 do
wait(1)
print(i)
Status.Value = "My Text here (" ..i..")"
if i == 0 then
Status.Value = ""
end
end
This is a very interesting case, the code works flawlessly in my studio which further leads me to believe this code is not the reason you’re receiving this error.
Are there any other scripts that you believe could be of any relevance to this problem?
So looks like changing the wait() to 0.8 seems to fix it. As I mentioned, I believe it seems that the IntValue is going faster while the script gets delayed for 2 seconds. So I’ll mark that as the Solution. Although tysm for the info y’all!