So im currently making my own custom leaderboard ui and i would like the “player viewer” to disappear if the player clicks anywhere off it.
So my question is, is there any way to detect if the player clicks but doesnt click any of the buttons available. Basically functioning like the default leaderboard system (you view the player but if you click anywhere else it auto closes)
Check for a click and get the GUI objects at the mouse’s position:
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local atPos = PlayerGui:GetGuiObjectsAtPosition(input.Position.X, input.Position.Y)
if atPos == 0 then
-- your code
end
end
end)
My bad I accidentally put “MouseClick” when it should’ve been “MouseButton1” for the UserInputType