Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years 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

1 answer

Log in to vote
0
Answered by 6 years 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 2009 — 6y
0
Seemed to work so... BennyBoiOriginal 293 — 6y
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 293 — 6y
Ad

Answer this question