Ad
Log in to vote
0

Why is this script unreliably disabling a script in a player's character? [Answered]

Asked by 9 days ago
Edited 9 days ago

So I have a server script that is in StarterCharacterScript that's about Pathfinding. I have another script that handles the game and how it runs. After some time, the GameManager script is supposed to loop through the players in game.Players and get their character and disable the Pathfinding script which most of the time, it doesn't do and sometimes one player has it enabled by the GameManager script.

GameManager (shortened because the other parts were irrelevant):

for i,v in pairs(game.Players:GetPlayers()) do

    v.Character.Pathfind.Disabled = false   

end

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

Log in to vote
0
Answered by 9 days ago

Seemed to fix it by adding a while wait() do loop around the for i,v in pairs(game.Players:GetPlayers()) do.

1
because.... your checking every 30th of a second and not just once hiimgoodpack 1378 — 9d
0
Seemed to work so... BennyBoiOriginal 163 — 9d
0
Or maybe I did something else that fixed it, honeestly I have no clue. I just seem to think that its what fixed it. BennyBoiOriginal 163 — 9d
Ad

Answer this question



Ad