I am trying to make Roblox show a GUI when you click another player and it does not print my print statement
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.Button1Down:Connect(function() if Mouse.Target.Parent:FindFirstChild("Humanoid") then local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent) print(Mouse.Target.Parent.Name) end end)
Works perfectly fine for me proof
But i recommend adding this (it prevents a error when you click at something that is nil / e.g the sky):
if Mouse.Target then end
How it would look in the script:
Mouse.Button1Down:Connect(function() if Mouse.Target then if Mouse.Target.Parent:FindFirstChild("Humanoid") then local clickedPlayer = game.Players:GetPlayerFromCharacter(Mouse.Target.Parent) print(Mouse.Target.Parent.Name) end end end)