FireClient preventing "for" loop

I have this boost table, that is stored in “playerData”. Once the player is added, a loop runs every second to remove a second off of the boost time. This works fine, up until I try using FireClient.

This code here is without FireClient:

image

and here is the output of the script:

image

As you can see, the both active boosts are printed and the timer is going down.

Now, here is the code with the FireClient included:

And the output:

image

For some odd reason, only one of the active boosts is ticking down, and I have zero idea why. Any help is appreciated, thanks.

1 Like

The reason why only one boost is ticking down when you have fired the client is because something in your code is erroring making it so the loop will not play again. We’d assume the FireClient line is erroring and isn’t running because this only happens when that line is added. It still works for one of the values since the code before it does not error when it changes the value of the key.
The reason why it won’t look like it’s erroring is because it’s in a pcall. We can diagnose the problem by setting up the pcall like this:

local success, errormessage = pcall(function()
--- Your code in here
end)
if errormessage then 
   warn(errormessage)
end

Look at what is erroring and you should be able to fix it since you seem to be a proficient programmer. Let me know if you need more help and if you fix it by yourself I’d also love to know what the issue is. Goodluck bro I hope this helps.

Tysm, the mistake was so dumb lol. Basically, I use 2 places, the first is the lobby, the second is the match. Now, I use datastores, so I took the code from my datastore script from the lobby, and pasted it into the match datastore script.

The lobby script worked fine, because the events are all located in replicated storage, and in the match, the events are in folders.

I forgot to redirect the path to the event.

I feel so dumb lol.

1 Like

Haha bro it’s all good. It’s happened to me so many times where I don’t print out any errors from a pcall and I just get stuck. Hope your game goes great bro.

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