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

How do I instance a frame into a billboard gui and make it visible?

Asked by 6 years ago
Edited 6 years ago

Hello again, So i'm new to scripting/coding but im trying to learn instancing. So, I wanted to try out instancing a BillboardGui into a part, then instance a frame into BillboardGui. But when it instances the both things, the frame wont be visible! And no, I dont mean the property Visible. I checked the output also, but no errors . Please help me, thanks ;) . Here is the script I have:

script.Parent.Parent.ClickDetector.MouseClick:Connect(function()
    script.Parent.Parent.Anchored = false
        Instance.new("BillboardGui", game.Workspace.Tree.Wood)
        wait()
        Instance.new("Frame", game.Workspace.Tree.Wood.BillboardGui)

    end)

EDIT: Here are some images:

https://imgur.com/TGp0zpX - Explorer showing that they are instanced. https://imgur.com/PPYaMr4 - Properties showing that it's visible. https://imgur.com/GVYZJ6A - Game showing that you can't see the frame. https://imgur.com/meREzVk - Output, error is one of the plugins.

1 answer

Log in to vote
0
Answered by 6 years ago

Hello!

In the script, you forgot to set the BillboardGui and Frame's Size properties.

To fix this, add a line of code and 2 variables before the instancing of the BillboardGui and Frame and...

script.Parent.Parent.ClickDetector.MouseClick:Connect(function()
    script.Parent.Parent.Anchored = false
    GUI = Instance.new("BillboardGui", game.Workspace.Tree.Wood) -- GUI is the variable.
    wait()
    local Frame = Instance.new("Frame", game.Workspace.Tree.Wood.BillboardGui) -- Added a variable before instancing of Frame.
    GUI.Size = UDim2.new(0,300,0,300) -- You can change the size if you want.
    Frame.Size = UDim2.new(1,0,1,0) -- You can change the size if you want.
 end)

BOOM. For a simplier code:

script.Parent.MouseClick:Connect(function() -- The script's parent is already the ClickDetector.
    script.Parent.Parent.Anchored = false
    local GUI = Instance.new("BillboardGui", script.Parent.Parent) -- The ClickDetector's parent is the Wood part.
    -- The wait() function isn't necessary.
    local Frame = Instance.new("Frame", GUI) --Sets the new frame instance's parent to the BillboardGui in no time.
    GUI.Size = UDim2.new(0,300,0,300)
    Frame.Size = UDim2.new(1,0,1,0)
 end)
-- Remove all the comments (text colored in green) or leave them if you want.

For more about UDim2, see: http://wiki.roblox.com/index.php?title=UDim2

For more about Variables, see: http://wiki.roblox.com/index.php?title=Variable

Hopefully this answer helped!

Ad

Answer this question