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

How do i make a textbox and button appear when i click a box?

Asked by 7 years ago

What im trying to do is i have a box and when i click it i want a text box and button to appear, and when i click the button it goes away. the problem is that when i click the box it wont become visible! my script:


pine = workspace.pine repeat if pine.ClickDetector.MouseButton1Click:connect(function(b) then game.StarterGui.ScreenGui.TextBox.Visible = true game.StarterGui.ScreenGui.TextButton.Visible = true end

2 answers

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

You've combined an if statement with a function. Although this doesn't fix it, I'll show you what you did wrong. Change this line:

if pine.ClickDetector.MouseButton1Click:connect(function(b) then

To this:

pine.ClickDetector.MouseButton1Click:connect(function(b)

And at line 6, change:

end

To:

end)

Also, the whole thing wouldn't work anyway. You need to put this script into the StarterGui and redo it because I'm assuming you only want this to happen to the player who clicked the box, not to everyone in the game.

0
i tweaked the script, placed it in the right area, and i turned the default setting for the textbox and button's visibility to false, but now when i clikc the box, it wont make the text box visible roblozinko 15 — 7y
0
Show me what the script looks like , and where you've put it. It should also be a local script. ThePhantomG 30 — 7y
0
Wow you got an answer accepted but this would only open it? Wow.... So low H4X0MSYT 536 — 7y
Ad
Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
7 years ago
Edited 7 years ago

Theres a simple method of turning 5 lines into one for this kind of thing. also the repeat and if statement are useless in this. You are declaring an event listener. This will fire whenever it happens, no need to constantly check for it.

pine.ClickDetector.MouseButton1Click:connect(function(p) -- declare the listener
    game.StarterGui.ScreenGui.TextBox.Visible = not game.StarterGui.ScreenGui.TextBox.Visible -- not statement will reverse the current visible. if true, false. if false, true.
        game.StarterGui.ScreenGui.TextButton.Visible = not game.StarterGui.ScreenGui.TextButton.Visible -- same thing for other gui object.
end)

EDIT: found the other answer is just as useless... game.StarterGui.ScreenGui changes the StarterGui. Not what the players see. For this to update, the player needs to be killed or respawned. You must go into the players version of the gui with something like

game.Players[p.Name].PlayerGui.ScreenGui.Textbox.Visible = not game.Players[p.Name].PlayerGui.ScreenGui.Textbox.Visible -- just so the player sees the change.

HOWEVER: Local scripts should be used for this kind of thing.

0
alright, thank you! now how do i get the button to work? roblozinko 15 — 7y
0
With an event listener. Line 1 and 4 of the first code block. H4X0MSYT 536 — 7y

Answer this question