Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you create an on screen GUI?

1 answer

✓ Accepted answer

What people normally do,

Normally, what a lot of people do is create the GUIs first, in StarterPack, and activate them when necessary. So, for example, people might have a LocalScript in a TextButton on the side of the screen, and have a script inside of the button. When the script detects a click, it would open a Frame that would have other stuff in it that the player could interact with. The LocalScript would look similar to this,

--LocalScript in a TextButton,

local Frame = script.Parent.Parent:WaitForChild("Frame")--Define Frame

script.Parent.MouseButton1Down:connect(function(mouse)
	if Frame.Visible == true then
		Frame.Visible = false
	else
		Frame.Visible = true
	end
end)
The above it what a lot of people do. People use this method because it's simple and quick.

How To Make Everything With A LocalScript

The method is harder, takes longer, and is a bit more complicated. The method, however, is needed for some situations. We'll be creating Instances with the Instance.new function. Let's first make the ScreenGui that we'll be putting everything in.

-- LocalScript in StarterGui, or ReplicatedFirst, or even StarterPack

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local ScreenGui = Instance.new("ScreenGui", plrGui)-- makes and parents

Now we need to make a Frame, and parent it the the ScreenGui

-- LocalScript in StarterGui, or ReplicatedFirst, or even StarterPack

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local ScreenGui = Instance.new("ScreenGui", plrGui)
local Frame = Instance.new("Frame", ScreenGui)-- Makes and Parents

Now we need to make the TextBox, or something else, and set some properties of the Frame.

-- LocalScript in StarterGui, or ReplicatedFirst, or even StarterPack

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local ScreenGui = Instance.new("ScreenGui", plrGui)
local Frame = Instance.new("Frame", ScreenGui)
local TextBox = Instance.new("TextBox", Frame)-- Makes and Parents

Frame.Size = UDim2.new(1,0,1,0)
Frame.BackgroundTransparency = 1

TextBox.Text = "yay, it works!"

You could of course do more with this, and add more to this. For more info, check here. The link is a tutorial the uses the above.

Good Luck!

This discussion is preserved as it was. New answers, comments, and votes are closed.