Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Printing NPC Name Works But Not Player Name?

Asked by 5 years ago

I have a script that makes it where when you left click on a NPC or player, it will print their name. For example, if you target a NPC named "Bob", it will print "Bob." If you click on a player with the name of "targetMe123," it will print "targetMe123." The only problem is, with the current code I have, it's only working on NPCs and not players.

Here's my code that I have:

mouse.ButtonDown1:connect(function()
    if mouse.Target ~= nil and mouse.Target.Parent.Humanoid then
        local currentTarget = mouse.Target.Parent.Name
        print(currentTarget)
    end
end)
0
What's it printing instead? davidgingerich 603 — 5y
0
I found out the problem. You see, the player torso and head have Collide = false. It will print their names if they click the arms or legs. Now I'm wondering, is there a way I can keep the torso and head the same but not click right through them? Like clicking a non collidable block? volgrok100 0 — 5y
0
maybe add a new block on the position of the torso and head and weld it to them? RobuxMaster8912 15 — 5y
0
Okay, I'll try that. Thanks volgrok100 0 — 5y

Answer this question