Get the other player playermodule from localscript

Hello,
I get the problem. I trying to catch the playermodule other player from localscript on other player.
I’m just trying to turn off the controls of another player.
I use a tool on start that’s how i get a other player.
My error is PlayerScripts is not a valid member of Player “Players.Player1” and i know the player can’t see the other player’s script but i need to get it. How can i disable this controls player?
Script:

local player = script.Parent.Parent.Parent
local remote = game.ReplicatedStorage.zakuc
script.Parent.Part.Touched:Connect(function(ppl)
	local hum = ppl.Parent:FindFirstChildOfClass('Humanoid')
	local plr = game.Players:GetPlayerFromCharacter(ppl.Parent)
	if ppl.Parent ~= nil and hum~= nil then
		player.PlayerGui.Kajdanki.Enabled = true
		remote:FireClient(player,plr)
	end
end)

LocalScript

local remote = game.ReplicatedStorage.zakuc
local de = false
script.Parent.MouseButton1Click:Connect(function()
	remote.OnClientEvent:Connect(function(plr)
		local PlayerModule = require(plr.PlayerScripts:WaitForChild("PlayerModule"))
		local Controls = PlayerModule:GetControls()
		if not de then
			de = true
			Controls:Disable()
		else
			de = false
			Controls:Enable()
		end
	end)
end)

Thanks for help :hearts:

1 Like

You can instead, fire a remote event from client to server, and have the server disable the target player’s playerscripts.

2 things to note here
First, every time you press the script.Parent (Assuming it’s a GuiButton)
it will create a remote.OnClientEvent script connection every time, which in turn will create memory leaks using up more resources than normal if you decide to press the button a handful of times, i suggest you do the method i posted
above instead.
Secondly, as per usual with filtering enabled, even if you had access to another player’s playermodule you can’t disable it from another localscript. because the changes do not affect what’s getting replicated from server → client

1 Like

Well, I don’t think you can grab other player’s PlayerModule on neither client or server.

Yeah, PlayerScripts containers don’t replicate to the server.