Hii Guys! Working on a game rn and for the duration of a round, I need to be able to stop players from moving. However, I still need to be able to move them using a script during the round hence why I’ve decided to not anchor the player or set their walkspeed to zero. (If I do re-enable either of those for the script to work it allows the player to move themselves as well). Consequently, I’ve decided to use controls.
However, with this section of code I’m getting the infinite yield possible error when waiting for the PlayerScripts and I’m not too sure how to fix it. I should mention I’m doing everything related to controlling the round itself using a single server script. So far everything else is working.
-- Disable Controls
for i, Player in pairs(game.Players:GetPlayers()) do
local player = Player
local playerScripts = player:WaitForChild("PlayerScripts")
local PlayerModule = require(playerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
Controls:Disable()
end