Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I find a players name and team they're in by using a tool and clicking on them?

So, I'm making a tool and I'm trying to figure out how to get a players name and what team they're in

How the tool works is you would click the person you want to scan and it will display their name and depending on what team they are in it will display a certain message

The whole displaying bit I can do I just want some help with the whole finding player and all that.

Thanks

2 comments

0

script plz

0

There is no script, that's why I'm asking how it can be done

1 answer

you can use the Button1Down event of the players mouse and use a generic for loop to loop through all the players and check if the target is them.

ex

--client

local player = game.Players.LocalPlayer
local tool = script.Parent -- lets say this was the tool

tool.Equipped:Connect(function(mouse) 
	mouse.Button1Down:Connect(function() -- when the players clicks then
		if mouse.Target then
			for _,v in pairs(game.Players:GetPlayers()) do -- literate through all the players
				if mouse.Target.Parent == v.Character then
					print(v.Name, v.TeamColor) -- prints the name and teamcolour of the player
					break -- breaks the loop
				end
			end
		end
	end)
end)

2 comments

0

also it doesnt work on ur own character

0

See below for updated code

This discussion is preserved as it was. New answers, comments, and votes are closed.