Trouble with getting player character

Hi everyone! I know is a basic question and i know there are a lot of answers about but i can’t find any for like an hour and i feel stupid right now.

I have a Part, this part has a ClickDetector

everytime i click i want to check if the player who clicked has on his hand a definite tool

i was actually using this script
local tool = player.Character:FindFirstChild("ToolName")

but actually i remembered that player will refer to the player class and not to workspace and it wasn’t working, i searched also on roblox official guide but the script

[Note from the official guide] “But from the server it’s fine to do this:”

 if player.Character then
-- do something

I actually need to find this with ServerScript if possible:

How can i check that?

If you’re using a Click Detector, the click event passes a player variable.

So you could use this code in your server script

local clickDetector = script.Parent

      print(player.Name, 'clicked the button!')
    local character = plr.Character --Get player character from click detector
1 Like

Actually worked, i didn’t knew that (player) inside the function would be so much important, i have still a lot to learn, thanks both!