Getting a Players Tools

The Player, not a card (30 chars)

Why don’t you try doing print(hit.Name) to see what is hitting the sensor. (Right before line 2)

It printed about 50 times saying all different parts like RightLowerArm

Great, so the function fires. Try putting the print(h.Name) right after we identify what h is, and not after we check if h is nil or not.

I get the error Attempt to Index nil with Name

Did you correct this? Because I’m pretty sure the f is supposed to be lowercase, that might be the reason why.

Its not. Instance | Documentation - Roblox Creator Hub

Whenever I use FindFirstChild I always lowercase the f, it works out just fine for me. I’d say even if the documentation says otherwise, you should try it anyway.

I get the error Attempt to Index nil with Name on the line of print(h.Name)

Let me open studio so I can work out the kinks, as this conversation is limited in its capacity to communicate. Give me a couple of minutes.

The script works for me, flawlessly. Unfortunately, the file isn’t wanting to upload to this reply, so instead, I’ll upload it to youtube and provide the link. This reply will be edited with the said link once it’s uploaded.

Link: https://youtu.be/Ji-RmSVtKN8

1 Like

Can I see a screenshot of the code?

Also you may want to change the solution to the more perfected code because the one you marked as solved is actually faulty. Do this for others experiencing this issue.

Its working now, thanks so much!

1 Like

I personally just need an if statement for this.

if (Clicked an Object) and (has tool) then

How would I go about this?

ClickDetector.MouseClick:Connect(function()
if --[[bool value, set true if tool is equipped]] then
-- code
end
end)

What would I put in bool value?

if statements only go through if the value is true.

local variable = true

if variable then
print("Hi")
end

-- expected output: "Hi"

local variable = false

if variable then
print("Hi")
end

--expected output: Nothing

That’s why.

1 Like

So… How would I make it so if they have a tool and they Click a part then it would run the if-then statement?
Not just a portion of the script?