How would you select a player, when you click on the player? And I'm thinking of also asking about how you would make it push the player backwards, and an animation pop up on you.
COMMUNITY QUESTION
How would you use a mouse to select players when clicked?
2 answers
It depends what you mean by "Select a player."
To start out, if I were you I would probably write a script to insert a ClickDetector to each of the Player's limbs when they join the game, then write a script that detects when the ClickDetector is clicked.
function assignClick(Player)
ClickDetector = Instance.new("ClickDetector")
p = game.Workspace.Player:GetChildren()
for i,v in pairs(p) do
if v:IsA("Part") then
ClickDetector.Parent = v
else
return
end
end
end
game.Players.PlayerAdded:connect(assignClick)
That script should assign ClickDetectors in each of the Player's limbs.
noooo i would not use click detectors. I would use the mouse in a LOCAL script.
local p = game.Players.LocalPlayer
local m = p:GetMouse()
function showprofile(player) -- change this to a gui, or whatever
print(player.AccountAge)
print(player.userId)
print(player.Name)
end
m.Button1Down:connect(function()
local target = m.Target
if target and target.Parent and m then
if game.Players:GetPlayerFromCharacter(target.Parent) then
showprofile(game.Players:GetPlayerFromCharacter(target.Parent))
end
end
end)
using the mouse is a lot easier and cleaner than using a click detector.
2 comments
0
NOTE; this is to only work to profile other people, you cannot click yourself.
0
How would I change it to a GUI?
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
How would I do that?
I've edited my answer to include some code.