Disabling and Enabling controls?

I have made these two functions in my module script.

function moonlightFramework.disableControls(player)
	local PlayerModule = require(game.Players.player.PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end
function moonlightFramework.enableControls(player)
	local PlayerModule = require(game.Players.player.PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Enable()
end

Now, when I try run the functions in my server sided script, which is below, I get an error of player is not a valid member of Players "Players"

Server Script:

local moon = require(8288681721)

moon.disableControls(game.Players:WaitForChild("callmehSpear"))

I believe the rror has something to do with local PlayerModule = require(game.Players.player.PlayerScripts:WaitForChild("PlayerModule"))

Cheers for any help.

is callmehSpear your user or are they in game?

My username

charrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

Here is the issue, change this to

game.Players[player].

Edit: it is looking for a player called “player” in the game instead of looking for the value of player variable.

function moonlightFramework.disableControls(player)
	local PlayerModule = require(game.Players.[player].PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end

the [] brackets give me an error.

dont put a full stop infront of it

I get this error now., required_asset_8288681721.MainModule:58: invalid argument #2 (string expected, got Instance)

(and yes i am uploading it each time)

Change to this

function moonlightFramework.disableControls(player)
	local PlayerModule = require(game.Players[player].PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end

required_asset_8288681721.MainModule:58: invalid argument #2 (string expected, got Instance)

Server Script:

local moon = require(8288681721)

wait(5)
moon.disableControls(game.Players:WaitForChild("callmehSpear"))

Module Script:

function moonlightFramework.disableControls(player)
	local PlayerModule = require(game.Players[player].PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end
function moonlightFramework.enableControls(player)
	local PlayerModule = require(game.Players[player].PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Enable()
end

All the other functions I made like kick, API, point system still work.

function moonlightFramework.disableControls(player)
	local PlayerModule = require(game.Players[player.Name].PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end

or just

function moonlightFramework.disableControls(player)
	local PlayerModule = require(player.PlayerScripts:WaitForChild("PlayerModule"))
	local Controls = PlayerModule:GetControls()
	Controls:Disable()
end