Still have questions? Join our Discord server and get real time help.
0

# Checking if the Player clicked another player?

Edited 13 days ago

So this may seem confusing but I want to know how you find which player character a user has clicked then show a GUI using that players image, I'd think it'd be something like

local player = --Don't know
local cd = --A ClickDetector or something else

cd.MouseClick:Connect(function()
script.Parent.Image = "https://web.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&Format=Png&userid="..player.UserId
end


Any help is appreciated, thanks!

0
Edited 13 days ago

A little something like this should do, all i'm doing is using getting the Mouse.Target which you can learn about here after the player presses down on the left mouse button which you can learn all about the mouse here

local Player = game.Players.LocalPlayer -- Getting the player
local Mouse = Player:GetMouse() -- Getting the players mouse]

Mouse.Button1Down:Connect(function() -- Detecting when the player presses the left mouse button

if Mouse.Target.Parent:FindFirstChild("Humanoid") then -- Checking if the Mouse is over a player
print(Mouse.Target.Parent.Name) -- replace this with whatever code you want
end

end)


and you can get the player from the character by doing

local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent)

0
Yes It worked, thank you! Notrealac0unt 19 — 13d
0
No problem KinqAustinn 276 — 13d