Hello so I ask you guys, if you now how to get the player from a Equipped event(Serverscript in the tool)?
The tool is parented to the player’s character when equipped, because of that you can use Players:GetPlayerFromCharacter.
local players = game:GetService("Players")
local function OnEquipped()
local char = tool.Parent
local player = players:GetPlayerFromCharacter(char)
if player then --check if player was found, maybe it's an npc
print(player)
end
end
1 Like
Could always check for the Parent of the Tool that was equipped, such as:
local players = game:GetService('Players')
local player = Tool.Parent.Name
if players:FindFirstChild(player) then
player = players[player]
end
@mniao has a more thought-out way.
script.Parent.Equipped:Connect(function()
game.Players:GetPlayerFromCharacter(script.Parent.Parent)
end)
assuming the script is in the tool
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.