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

Help me with my GUI?

Asked by 9 years ago

I don't understand how to code for GUIs. I'm trying to have pressing 1 button lead to another button appearing, and the original disappearing, but I have no idea how to do that. This is my first time ever scripting, so I'm really lost.

-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent


local textButton = Instance.new("TextButton")
textButton.Parent = screenGui
textButton.Position = UDim2.new(.25, 0, .25, 0)
textButton.Size = UDim2.new(.1, 0, .1, 0)
textButton.BackgroundColor3 = BrickColor.White().Color
textButton.Text = "Click Me!"


textButton.MouseButton1Down:connect(function()
textButton2 = Instance.new("TextButton")
textButton2.Parent = screenGui
textButton2.Position = UDim2.new(.25, 0, .25, 0)
textButton2.Size = UDim2.new(.1, 0, .1, 0)
textButton2.BackgroundColor3 = BrickColor.White().Color
textButton2.Text = "Hi!"

Also, how do you make pressing a specific GUI make other GUI's disappear, and have GUIs give players int values? All I need is a written explanation, not a code.

1 answer

Log in to vote
0
Answered by 9 years ago

You seem to understand a bit of what you're doing so I'll just tell you some things you're doing wrong. first of all, you have no ends anywhere. You need an end at line 14 to close the function you've made.

textButton.MouseButton1Down:connect(function()
--Code here
end) -- Don't forget that parenthesis 

Also, you're making GUI's so you should really be using Local Scripts!! Due to using a Local Script, we can get that character who wants to manipulate the GUI and create the GUI for that player, like this:

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer.PlayerGui

I am not sure if you way of coloring is a way of doing it, and if I'm right then I will show you how I do it, at least:

TextBox.BackgroundColor3 = Color3.new(1,1,1) -- This makes it white, 1 = 255, goes up 25 every .1

So, here is an example of how to press a button and create a second one. My hierarchy will differ so just examine the code to know how.

script.Parent.MouseButton1Down:connect(function()
    local i = Instance.new("TextButton")
    i.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui
    i.Position = UDim2.new(0.1,0,0.2,0)
    i.Size = UDim2.new(0.1,0,0.1,0)
end)

The above script is not going to look "pretty" its just random spots and sizes I quickly picked plus the ScreenGui already exists.

Ad

Answer this question