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

BillboardGui not showing up in PlayerGui?

I am making a sandbox game in roblox, one where anyone can make their own obby. I have a Billboard Gui in StarterGUI that shows up whenever someone clicks an object. When i click the object, it says that BillboardGUI is not a valid member of PlayerGui. The game works perfectly when i test it in studio, but not when i play it in Roblox Player. I have no idea what's going on, could someone please help me?

Edit:

The script that i was using was in the part that was clicked, and this is the script:

part = script.Parent.Parent

part.ClickDetector.MouseClick:connect(function(player)
	local billboard = player.PlayerGui:WaitForChild("BillboardGui")
	billboard.Adornee = part
	if billboard.Enabled == true then
		billboard.Enabled = false
	else
		billboard.Enabled = true
	end
end)

1 comment

0

What is the script you are using?

2 answers

✓ Accepted answer

It's usually because you didn't wait for the BillboardGui to "exist". You see, scripts start even earlier before some things even exist (load into the game). Use a WaitForChild().

For example, like this:

local starterGui = script.Parent
local billBoardGui = starterGui:WaitForChild("BillboardGui")
-- the rest of the code goes here, use the "billBoardGui" variable. Or whatever you called it.
billBoardGui:Destroy() -- this will wait for the BillboardGui to load or exist, then destroy the BillboardGui. An example..

Edit:

Try this.

part = script.Parent.Parent
part.ClickDetector.MouseClick:connect(function(player)
    local playerGui = player:FindFirstChild("PlayerGui")
    local billboard = playerGui:WaitForChild("BillboardGui")
    billboard.Parent = part
    if billboard.Enabled == true then
        billboard.Enabled = false
    else
        billboard.Enabled = true
    end
end)

Though, I think this may only work once.

11 comments

0

the script i was using needed to go in the part that was being clicked.

0

sry i probably should have said that before

0

Then do that. I was just saying that you needed to use WaitForChild()

0

now it says "Infinite yield possible on 'player.PlayerGui:WaitForChild("BillboardGui")' "

0

i edited the script in the question

0

Did you set the Parent of the billboard to the part?

0

no, i just need to set the adornee of the billboard to that part.

0

with the script you suggested, it still says the same error message.

0

Oh, well I guess I don't quite know.. Sorry D:

0

I'll try using a regular ScreenGui instead of BillboardGUI.

0

Thanks for trying!

Tiny edit on Xrp200's code:

part = script.Parent.Parent
part.ClickDetector.MouseClick:connect(function(player)
    local playerGui = player:FindFirstChild("PlayerGui")
    local billboard = playerGui:WaitForChild("BillboardGui", 50)
    billboard.Parent = part
    if billboard.Enabled == true then
        billboard.Enabled = false
    else
        billboard.Enabled = true
    end
end)

We have no specified the time argument of WaitForChild. With no argument, it waits a super tiny amount of time. With this instead, it waits for it for a long time (50 secs). In the case it's not working, try this:

part = script.Parent.Parent
part.ClickDetector.MouseClick:connect(function(player)
    local playerGui = player:FindFirstChild("PlayerGui")
    local billboard = playerGui:FindFirstChild("BillboardGui", 50)
    if billboard == nil then
        local billboard = playerGui:WaitForChild("BillboardGui", 50)
    end
    billboard.Parent = part
    if billboard.Enabled == true then
        billboard.Enabled = false
    else
        billboard.Enabled = true
    end
end)

This other code will check if the billboard exists. If it doesn't, it will wait until it is created for more time(50 secs).

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