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

Why doesn't this billboardgui textbutton not show up when I walk to the part?

I have a placement system, and I have it so that when you equip a tool, and click it will clone the structure into workspace and create a billboardgui with a textbutton inside of a screengui inside of startergui. The problem is, I tested it and the TextButton doesn't show up. Here is the script:

game.ReplicatedStorage.RemoteEvents.PlaceStructure.OnServerEvent:Connect(function(Player,Structure,PrimaryCFrame)
	if Structure == "Workbench" then
		local Clone = game.ReplicatedStorage.Structures[Structure]:Clone()
		Clone.Parent = game.Workspace
		Clone:SetPrimaryPartCFrame(PrimaryCFrame)
		local BillBoardGui = Instance.new("BillboardGui")
		local TextButton = Instance.new("TextButton",BillBoardGui)
		local ScreenGui = Instance.new("ScreenGui",game.StarterGui)
		BillBoardGui.Parent = ScreenGui
		BillBoardGui.Adornee = Clone.Center
		BillBoardGui.AlwaysOnTop = true
		BillBoardGui.MaxDistance = 17
		TextButton.BackgroundColor3 = Color3.fromRGB(85,170,255)
		TextButton.BorderSizePixel = 0
		TextButton.Size = UDim2.new(0,50,0,50)
		TextButton.Position = UDim2.new(0,70,0,0)
		TextButton.Visible = true
		TextButton.MouseLeave:Connect(function()
			TextButton.BackgroundColor3 = Color3.fromRGB(85, 170, 255)
		end)
		TextButton.MouseEnter:Connect(function()
			Clone.Top.Hover:Play()
			TextButton.BackgroundColor3 = Color3.fromRGB(54, 108, 162)
		end)
		TextButton.MouseButton1Click:Connect(function()
			Clone.Top.Click:Play()
		end)
	else
		local Clone = game.ReplicatedStorage.Structures[Structure]:Clone()
		Clone.Parent = game.Workspace
		Clone:SetPrimaryPartCFrame(PrimaryCFrame)
	end
end)

1 comment

0

I meant why doesn't it show up*

1 answer

✓ Accepted answer

When you want a GUI to show up while the player is in the game, use PlayerGui. This is so then the GUI can show up for the player, hence the name "PlayerGui". The reason we have StarterGui, StarterPack, etc. is that the children of those services will replicate to the player, but they are NOT able to be replicated UNTIL the player joins OR resets, hence the "Starter" in their names. So your problem is on Line 8 when you parent the ScreenGui. Its parent must be PlayerGui, not StarterGui.

local ScreenGui = Instance.new("ScreenGui",player.PlayerGui) -- player is an argument in your function

Edit: So basically if you want a GUI to show up even though the player didn't reset or do anything but trigger your RemoteEvent, then use PlayerGui.

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