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)
game.StarterGui.ScreenGui.TextBox.Visible = not game.StarterGui.ScreenGui.TextBox.Visible
game.StarterGui.ScreenGui.TextButton.Visible = not game.StarterGui.ScreenGui.TextButton.Visible
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
HOWEVER: Local scripts should be used for this kind of thing.
3 comments
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
Show me what the script looks like , and where you've put it. It should also be a local script.
Wow you got an answer accepted but this would only open it? Wow.... So low