How to get playerID from a Tool?

I have been searching around on the Developer forum but i can not the solution to my issue.

The problem that i am having is that the tool gets the profile ID of the player holding it And print it in the tool into the ID section.

Thank you for reading.!

The tool
help1

Where the ID suppose to be at
Help2

What you could do is get the player and then do player.UserId. Replace “player” with whatever you do to get the player

To do this, you’ll want to do:

local player = tool.Parent.Parent
local playerId = player.UserId

Because tool.Parent is the player’s Backpack, and the Backpack’s parent is the player.

2 Likes
--LocalScript in the tool Handle
local plr = game.Players.LocalPlayer

local plrId = plr.UserId--gets the players id
local UrRobloxId = script.Parent.Parent.UrRobloxId--gets UrRobloxId from the tool's handle
UrRobloxId = plrId-- sets UrRobloxId to the players id
1 Like

You can get the Player’s UserId from the Player’s LocalPlayer.

local Players = game:GetService("Players")
local UserId = Players.LocalPlayer.UserId
1 Like

Thank you and Inventfv for this useful information! With this i can finally finish my script.

2 Likes

Thank you and Drewel112233 for this useful information! With this i can finally finish my script.

1 Like