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

Creating a Character Stats display help?

Hi all, So today I'm trying to make a GUI that appears with a characters information when someone mouses over that character. So far I've only gotten it to work with a tool in hand. My goal is to not have to have any tool involved and just be able to mouse over the character and obtain his name and put it on a GUI.

Here's what I have so far:

wait(3)

local TOOL = script.Parent

local SCREEN_GUI = TOOL.ScreenGui
local FRAME = SCREEN_GUI.Frame

local TARG_LABEL = FRAME.NameLabel




function getPC()
	local player = TOOL.Parent.Parent
	local char = player.Character

	return player, char
end

function canUse(part)
	if part == nil then
		return false
	end
	local bool = false
	return bool
end


function onMouseMove(mouse)
	local targ = mouse.Target

	TARG_LABEL.Text = ""
	
	while targ == nil do
		wait(10000000)
	end

	if canUse(targ) and targ then
		if targ.Locked and targ then
				TARG_LABEL.Text = targ.Name
				--This shows what its looking for
		else
			end
	else 
			TARG_LABEL.Text = targ.Name
		end
	end


function onSelected(mouse)
	local player = TOOL.Parent.Parent
	local p_gui = player.PlayerGui

	SCREEN_GUI.Parent = p_gui

	mouse.Move:connect(function()
		onMouseMove(mouse)
	end)

end

TOOL.Selected:connect(onSelected)


Right now it grabs a brick name and displays it's name, but eventually I'll try and change it to get a characters name.

1 answer

✓ Accepted answer

Use player:GetMouse() in a local script. It will do the same as getting the mouse with the tool.

2 comments

0

With a little tinkering, it worked out perfectly. Thank you!

0

Np

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