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

How do you add a Clickable TextButton in a Billboard GUI?

Asked by 7 years ago

Is there a way to send click events through a Billboard GUI into a TextButton, so that the event MouseButton1Click/Down can be used on the TextButton? I have set the Active property in the Billboard GUI to true, I double checked the size of the Billboard GUI to make sure it is large enough, and I checked to see if any other elements were stealing the click.

This code is from a local script located inside a ScreenGui. The SelectGui is the Billboard GUI that has the button in it (also located inside the ScreenGui). ScreenGui is located in the StarterGui. Both the local script and the SelectGui have the ScreenGui as their parent.

if (Mouse.Target.Parent.Owner.Value == Player.Name) then
                script.Parent.SelectGui.SellButton.Visible = true
                script.Parent.SelectGui.SellButton.Text = "SELL ($" ..math.ceil(Mouse.Target.Parent.Cost.Value/2).. ")"
                print("Showing")
                script.Parent.SelectGui.SellButton.MouseButton1Click:connect(function()
                    print("Selling")
                    Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + math.ceil(Mouse.Target.Parent.Cost.Value/2)
                    Mouse.Target.Parent:Destroy()
                end)
            else
                script.Parent.SelectGui.SellButton.Visible = false
            end

I'm mostly interested in this line of code:

script.Parent.SelectGui.SellButton.MouseButton1Click:connect(function()
                    print("Selling")
                    Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + math.ceil(Mouse.Target.Parent.Cost.Value/2)
                    Mouse.Target.Parent:Destroy()
                end)

I'm nore sure if I am referencing the MouseButton1Click event incorrectly, or if is there a property in the Billboard GUI I forgot to change. Any comments and answers are appreciated!

1 answer

Log in to vote
0
Answered by
Zeluxis 100
7 years ago

What I'd suggest doing is the following;

make two frames, the first one and the one you want to appear after being clicked. Edit them to your hearts content. Now, make the one you wish to popup have its visible property set to false (unticked), and ensure the first one is set to true (ticked)

Now, with the following code, you SHOULD be able to make the second screen popup with the press of the textbutton on the first.

function Clicked()
    script.Parent.Visible = false
    script.Parent.Parent.PUTFRAMENAMEHERE.Visible = true
end

script.Parent.TextButton.MouseButton1Click:connect(Clicked)

If I helped, be sure to accept this as your answer, if not, I'd advise looking at the ROBLOX wiki!

0
Could you send me a link to the wiki page I should look at? GamerOkami 71 — 7y
Ad

Answer this question