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

How would you use a mouse to select players when clicked?

Asked by 10 years ago

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.

2 answers

Log in to vote
1
Answered by 10 years ago

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.

0
How would I do that? TheReapersComing 0 — 10y
0
I've edited my answer to include some code. SlickPwner 534 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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.

0
NOTE; this is to only work to profile other people, you cannot click yourself. TigerCaptain 75 — 10y
0
How would I change it to a GUI? TheReapersComing 0 — 10y

Answer this question