How would I figure out the player from a Module script within a tool

I need to find the player who is actively using the tool inside of this module script and I’m unsure of how to navigate to them. I assume it’s not like a local thing right?

If the tool is being held by the player (i.e. not in the backpack), it will be in their character model.
So from the Script, we can “parent up” until we reach the character, and then use the Players service to GetPlayerFromCharacter.

In this example
image
we can get the player with this code:

Player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
1 Like

This will work if the tool is equipped and being held by the player regardless of where the script is placed inside the tool itself.

local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(script:FindFirstAncestorOfClass("Tool").Parent)

This will work if the tool is unequipped and in the backpack of the player regardless of where the script is placed inside the tool itself.

local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(script:FindFirstAncestorOfClass("Tool").Parent.Parent)