Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

BillboardGui not showing up in PlayerGui?

Asked by 6 years ago
Edited 6 years ago

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)
0
What is the script you are using? Lava_Scripter 109 — 6y

2 answers

Log in to vote
0
Answered by
Nep_Ryker 131
6 years ago
Edited 6 years ago

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.

0
the script i was using needed to go in the part that was being clicked. VeryWowMuchDoge 47 — 6y
0
sry i probably should have said that before VeryWowMuchDoge 47 — 6y
0
Then do that. I was just saying that you needed to use WaitForChild() Nep_Ryker 131 — 6y
0
now it says "Infinite yield possible on 'player.PlayerGui:WaitForChild("BillboardGui")' " VeryWowMuchDoge 47 — 6y
View all comments (7 more)
0
i edited the script in the question VeryWowMuchDoge 47 — 6y
0
Did you set the Parent of the billboard to the part? Nep_Ryker 131 — 6y
0
no, i just need to set the adornee of the billboard to that part. VeryWowMuchDoge 47 — 6y
0
with the script you suggested, it still says the same error message. VeryWowMuchDoge 47 — 6y
0
Oh, well I guess I don't quite know.. Sorry D: Nep_Ryker 131 — 6y
0
I'll try using a regular ScreenGui instead of BillboardGUI. VeryWowMuchDoge 47 — 6y
0
Thanks for trying! VeryWowMuchDoge 47 — 6y
Ad
Log in to vote
0
Answered by
Aimarekin 345 Moderation Voter
6 years ago

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).

Answer this question