I have a remote function that, when invoked, will use the updated way of disabling the player's controls. The problem is that sometimes it simply does not do this sometimes (meaning it works) and it messes up the whole thing.

Server script:

local replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage.RE.Controls:InvokeClient(plr,true)

local script:

function controls(operation)
	if operation == true then
	local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
		local Controls = PlayerModule:GetControls()
		Controls:Disable()
	elseif operation == false then
		local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
		local Controls = PlayerModule:GetControls()
		Controls:Enable()
	end
	end
game.ReplicatedStorage.RE.Controls.OnClientInvoke = controls