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

How to make billboard GUI show up WITH text on mouse hover?

This is my code.. How do I make the billboard GUI show up when I hover over the part? Also how do I make it not be half inside the part its parented to?

local computerScreen = game.Workspace.ComputerScreen

local CursorId = "2287179355"
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = computerScreen
ClickDetector.MaxActivationDistance = 10
ClickDetector.CursorIcon = "rbxassetid://"..CursorId


local openGUI = Instance.new("BillboardGui")
openGUI.Parent = computerScreen
openGUI.Name = "OpenComputer"
openGUI.MaxDistance = 10
openGUI.Size = UDim2.new{1,0},{1,0}
openGUI.ExtentsOffset = Vector3.new(0,2,0)
openGUI.Enabled = false

local openText = Instance.new("TextLabel")
openText.Parent = computerScreen.OpenComputer
openText.Size = UDim2.new(28)
openText.Font = 10
openText.Text = "Open"
openText.Visible = false

ClickDetector.MouseHoverEnter:Connect(function()
	openGUI.Enabled = true
	openText.Visible = true
	print("Done")
end)

ClickDetector.MouseHoverLeave:Connect(function()
	openGUI.Enabled = false
	openText.Visible = false
	print("Done Left")
end)

2 comments

0

REFRESH FOR EIDT

0

Edit*

2 answers

✓ Accepted answer

You mostly had it, but there are a few things to note here.

  1. You need to set a GUIs Size and Position like so UDim2.new(0,0,0,0), without curly braces.
  2. Set the Parent of an object after you're done setting its properties.
  3. You need to set the Adornee of the part
  4. FontSize is the correct property for scaling, not Font.
  5. Enabling and Disabling the GUI doesn't serve a purpose here.
  6. AlwaysOnTop will make the GUI stay on top of objects.
local computerScreen = game.Workspace:WaitForChild("ComputerScreen")
local CursorId = "2287179355"
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.MaxActivationDistance = 10
ClickDetector.CursorIcon = "rbxassetid://"..CursorId
-- Parent after you're done setting properties
ClickDetector.Parent = computerScreen



local openGUI = Instance.new("BillboardGui")
-- AlwaysOnTop puts GUI on top of everything.
openGUI.AlwaysOnTop = true
openGUI.Name = "OpenComputer"
-- Set Adornee to computerScreen
openGUI.Adornee = computerScreen
openGUI.MaxDistance = 10
-- Don't use brackets
openGUI.Size = UDim2.new(1,0,1,0)
openGUI.ExtentsOffset = Vector3.new(0,2,0)
-- Parent after you're done setting properties
openGUI.Parent = computerScreen


local openText = Instance.new("TextLabel")
-- FontSize 7 = 24
openText.FontSize = 7
-- Set Size of TextLabel
openText.Size = UDim2.new(1,0,1,0)
openText.Font = 10
openText.Text = "Open"
openText.Visible = false
-- Parent after you're done setting properties
openText.Parent = computerScreen.OpenComputer


ClickDetector.MouseHoverEnter:Connect(function()
    openText.Visible = true
    print("Done")
end)

ClickDetector.MouseHoverLeave:Connect(function()
    openText.Visible = false
    print("Done Left")
end)

3 comments

0

BillBoard GUI still not showing

0

Edited, try again

0

Working. Thanks!

Add a ClickDetector into the part and then insert this into the part:

ClickDetect = script.Parent.ClickDetector
Billboard = script.Parent.BillboardGui
--make sure to add a BillboardGui with a TextLabel in it in the part.
--And add a ClickDetector in the part, too.
Billboard.TextLabel.Visible = false

ClickDetect.MouseHoverEnter:connect(function()
     Billboard.TextLabel.Visible = true
end)

If you want to make it disappear when exit, put what's above in with the following:

ClickDetect.MouseHoverLeave:connect(function()
     Billboard.TextLabel.Visible = false
end)

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