GUI on player mouse

So I was wondering, how do I make a GUI that appears on the mouse itself when I hover over a player’s character? This could be used for identifying a player’s name, account age or any other characteristic about the player.

4 Likes

Did you do some research before posting?

Here’s a link : How to Display an Items Name with Mouse Hover - Roblox Studio Tutorial

2 Likes

You could do a custom hitbox part for each character, and use mouse screen position and target to do the Gui changes.

Here is an exemple:

Capture

local PlayerService = game:GetService("Players")

local Player = PlayerService.LocalPlayer
local Mouse = Player:GetMouse()

local HitboxFolder = Instance.new("Folder")
HitboxFolder.Parent = workspace
HitboxFolder.Name = "Hitbox"

local function CheckHitbox()
	if Mouse.Target and Mouse.Target.Parent == HitboxFolder then
		script.Parent.Visible = true
		script.Parent.Text = Mouse.Target.Name
		script.Parent.Position = UDim2.fromOffset(Mouse.X, Mouse.Y)
	else
		script.Parent.Visible = false
	end
end

local function CreateHitbox(Player: Player, Character: Model)
	local Root = Character:WaitForChild("HumanoidRootPart")
	local NewHitBox = Instance.new("Part")
	local NewWeld = Instance.new("Weld")
	
	NewHitBox.Parent = HitboxFolder
	NewHitBox.Size = Vector3.new(3.5, 5, 1.5)
	NewHitBox.Transparency = 1
	NewHitBox.CanCollide = false
	NewHitBox.Name = Player.DisplayName
	
	NewWeld.Parent = NewHitBox
	NewWeld.Part0 = Root
	NewWeld.Part1 = NewHitBox
end

Mouse.Move:Connect(CheckHitbox)

for _, CurrentPlayer in pairs(PlayerService:GetChildren()) do
	local Character = CurrentPlayer.Character
	CreateHitbox(CurrentPlayer, Character)
end

PlayerService.PlayerAdded:Connect(function(NewPlayer)
	NewPlayer.CharacterAdded:Connect(function(Character)
		CreateHitbox(NewPlayer, Character)
	end)
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.