My variable cannot reference my Tooltip from the Player's Gui

I’m trying to make a tooltip that appears and changes text when I hover over a Viewpoint Frame but it doesn’t even show up. I have tried making the variable reference the frame from the Player’s PlayerGui but that left an error in the output which is below. I also tried to just reference it from StarterGui to see if that would work but that also did the same thing but left no error in nor the output or the console.

Error in output:

Local Script inside Viewpoint Frame:

local tooltip = game.Players.LocalPlayer.PlayerGui.TooltipUI.Frame

script.Parent.MouseEnter:Connect(function()
	tooltip.Visible = true
	tooltip.Text.Text = "Cube (3x3)"
	tooltip.Subtext.Text = "Basic building block for your level!"
	
end)

script.Parent.MouseLeave:Connect(function()
	tooltip.Visible = false
	tooltip.Text.Text = "Title"
	tooltip.Subtext.Text = "Display Info"

end)

Path in explorer:
Screenshot 2022-11-07 194052

Am I doing it in a wrong way? I could just try and list the entire path but I would rather not do that in the future.

Since this is defined in a localscript, make sure to use :WaitForChild() since some UI elements may take time to load.

Try:
local tooltip = game.Players.LocalPlayer.PlayerGui:WaitForChild("TooltipUI").Frame

Let me know if this doesn’t work, have a good rest of your day.

1 Like

The script worked and the tooltip is showing! Thank you!

1 Like

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