Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a GUI pop up when you hover your mouse over a player?

Hello fellow devs,

I want to make it so when a player hovers their mouse over another player's body, a GUI pops up with a couple of the groups said player is in. A picture of what I am envisioning is provided below! If anyone can provide me with some code I would be extremely grateful!

-0nionOnPremier, new dev

https://gyazo.com/1f3a18318c02f75dce889dec870a0505

1 comment

1

Sorry dude, hate to crash your party, but this is not a request site. We require that you please make an attempt and then come here for help. No code, no service.

2 answers

I don't know this but I found a code written in 2018 that could help you. I didn't write this

local Player = game:GetService("Players").LocalPlayer;
local Mouse = Player:GetMouse();
local UIS = game:GetService("UserInputService");
local RS = game:GetService("RunService");

local Gui = Instance.new("ScreenGui", Player:WaitForChild("PlayerGui"));
local Label = Instance.new("TextLabel", Gui);
Label.Size = UDim2.new(0, 100, 0, 10);
Label.AnchorPoint = Vector2.new(0.5, 0.5);

RS:BindToRenderStep("MouseHover", Enum.RenderPriority.Camera.Value - 1, function()
	
	local mPos = UIS:GetMouseLocation();
	Label.Position = UDim2.new(0, mPos.X, 0, mPos.Y);
	
	local Target = Mouse.Target;
	
	if Target then
		if Target.Parent then
			if Target.Parent:IsA("Model") and not (Target.Parent == workspace) then
				local tPlayer = game:GetService("Players"):GetPlayerFromCharacter(Target.Parent);
				if tPlayer then
					Label.Text = tPlayer.Name;
				else
					Label.Text = "Model: " .. Target.Parent.Name;
				end;
			else
				Label.Text = "Object: " .. Target.Name;
			end;
		else
			Label.Text = "Object: " .. Target.Name;
		end;
	else
		Label.Text = "nil";
	end;
	
end);
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gui = --your gui path here

game.Players.PlayerAdded:Connect(function(player)
	if mouse.Target == player then
		print("Player Found")
		mouse.Move:Connect(function()
			gui.Visible = true
			gui.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
		end)
	end	
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.