PlayerScripts is not a valid member of Player

Hello! I’m trying to disable player controls in a certain function. However, it keeps returning this error. I’m not really sure how to fix it.
obrazek

if newPlr ~= player and newChar:WaitForChild('Humanoid').Health > 0 then
								handleVars.curTarg = newPlr
								handleVars.curTargName = newPlr.Name
								tieEvent:FireServer(newPlr, 'Tie')
								local Controls = require(newPlr.PlayerScripts.PlayerModule):GetControls()
								Controls:Disable()
							end;

Try this you can remove the warnings if you want!

if newPlr ~= player and newChar:WaitForChild('Humanoid').Health > 0 then
    handleVars.curTarg = newPlr
    handleVars.curTargName = newPlr.Name
    tieEvent:FireServer(newPlr, 'Tie')
    local PlayerScripts = newPlr:WaitForChild("PlayerScripts")
    if PlayerScripts then
        local PlayerModule = PlayerScripts:WaitForChild("PlayerModule")
        if PlayerModule then
            local Controls = require(PlayerModule):GetControls()
            if Controls then
                Controls:Disable()
            else
                warn("Controls module not found for player: " .. newPlr.Name)
            end
        else
            warn("PlayerModule not found for player: " .. newPlr.Name)
        end
    else
        warn("PlayerScripts not found for player: " .. newPlr.Name)
    end
end```

Thanks! Though, it still doesn’t work. It returns a possible infinite yield warning.

It’s a little difficult to see from what code you’ve provided but are you trying to access a different players PlayerScripts folder?
A client can only access their own PlayerScripts folder.

You can’t access PlayerScripts through the server. Only the client that the PlayerScripts folder belongs to has access to it since it’s an instance made by their respective clients.

Following up on this, unless i’m reading this wrong, you can’t access other PlayerScript instances since it’s made on the client for the user.

It is a Local script, not a Server one.

Maybe if I implement a RemoteEvent, which will fire it to the server (as its a LocalScript) and then to the targetPlayer and control it on the client?