Finding local player through server script

So I’ve been encountering this problem recently, where I would have a script that detects if a player who stepped on a part had a specific tool in their backpack, or if I had to change a player’s walkspeed through their humanoid in workspace. Both of those examples would have to find who the localplayer is; How would I be able to do this simply and efficiently without having to use remote events? I found a few posts such as this one, but they all used remote events and I was wondering if there was another way without using remote events to find the local player through a server script.

1 Like

In the Players instance, there is a property called Players:GetPlayerFromCharacter(instance Character). You can have a player touch a part, when that part is touched, check for a Humanoid in touched.Parent. If a humanoid exists, you are able to set local Player to local Player = Players:GetPlayerFromCharacter(touched.Parent).


It’s actually fairly simple, we can get the Player object using the GetPlayerFromCharacter function provided by the Players service, which should hopefully return back it if the Part touched is a valid Player:

local Part = script.Parent

    local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
    if Player then
        local Character = Hit.Parent
        --Do your stuff here now that we have both the Player & Character objects
1 Like