Roblox Wiki
Register
Advertisement
Roblox Wiki
This page needs improvements to meet the Roblox Wiki's standards.
Please proofread or rewrite this page as necessary to ensure that it meets the Roblox Wiki's content and style standards. The specific problems are: formatting problems, outdated
Outdated information
The information on this article may be outdated. You can help the Roblox Wiki by updating it!
Tutorial page
This article is an intermediate tutorial.
Health

Health GUI

GUIs are on-screen displays that you can create to do just about anything. We will go over how to create a simple ForceField GUI in this lesson that only people you specify can use.

1. First, open Roblox Studio by opening up Start, clicking on All Programs, and scrolling down to ROBLOX. Then left-click on Roblox Studio. It'll launch to the Games page, hit New to work on a new map.

Step3

2. Once you have a new map, Select StarterGui by clicking on it, then press Insert > Object and select ScreenGUI then press OK.

3. Once you have this, select the ScreenGui, and we'll name it "ForceFieldGUI".

Newtextbutton

4. Now that you have your ScreenGui made, and named, we'll begin adding our first button, Select the ForceFieldGUI and press Insert > Object > TextButton then press OK.

Newscript

5. And then add a Script into the ForceFieldGUI.

6. In the script, insert this:

adminlist = {"Username","Player"}

function checkOkToLetIn(name) 
	for i = 1,#adminlist do 
		-- convert strings to all upper case, otherwise we will let in 
		-- "Username" but not "username" or "uSERNAME" 
		if (string.upper(name) == string.upper(adminlist[i])) then return true end 
	end 
	return false 
end 

	local human = script.Parent.Parent.Parent.Character
wait(2)
	if (human ~= nil ) then 
	local h2 = human:FindFirstChild("Torso")
	if h2 ~= nil then
	local h3 = h2:FindFirstChild("roblox")
	if h3 ~= nil then
		if h3.Texture == guishirt then --the shirt 
			-- a human has touched this door! 
			print("tshirt found") 
			-- test the human's name against the permission list 
		elseif (checkOkToLetIn(script.Parent.Parent.Parent.Name)) then 
			print("Human passed test") 
		else script.Parent:remove()
		end 
	end
	end 
end

You can then put in names that you want to be able to use the GUI.


7. Select the TextButton, change the following inside it to these values:

Forcefield

What the button should look like.

Name: ForceFieldGUI

BackgroundColor3: 177; 177; 177

Background Transparency: 0.4

BorderColor3: 177; 177; 177

BorderSizePixel: 0

Position: {0, 575}, {0, 10}

Size: {0, 75}, {0, 20}

Text: ForceField

TextColor3: 17; 17; 17

TextTransparency: 0.3

You will now have the basic button.

Udim2 Positioning[]

Before I go any more, I want to go over how UDim Positing works.

UDim3 Positioning

UDim has 2 ways to position the GUI in each axis, Scale and offset, Scale is relative to screen size, so if you said 0.5 for the Y Scale, the top of the GUI object would be in the middle of the screen.

The same for X. Offset is the offset in Pixels, so it would be in exactly the same position all the time when ROBLOX is resized.







8. Go ahead and Insert two more TextButtons. Edit the properties to these:

Name: ForceFieldON

BackgroundColor3: 177; 177; 177

BackgroundTransparency: 0.4

BorderColor3: 177; 177; 177

BorderSizePixel: 0

Position: {0, 575}, {0, 10}

Size: {0, 75}, {0, 20}

Text: On

TextColor3: 17; 17; 17

TextTransparency: 0.3

Visible: False

Next Button[]

Name: ForceFieldOFF

BackgroundColor3: 177; 177; 177

BackgroundTransparency: 0.4

BorderColor3: 177; 177; 177

BorderSizePixel: 0

Position: {0, 575}, {0, 10}

Size: {0, 75}, {0, 20}

Text: Off

TextColor3: 17; 17; 17

TextTransparency: 0.3

Visible: False


9. Insert a Script into all three of the buttons, and put the following script into the correct button:

ForceFieldGUI: (The button, NOT the ScreenGui)[]

function onClicked(GUI)
h = script.Parent.Parent.Parent.Parent.Character:findFirstChild("Humanoid")
if (h ~= nil) then

if script.Parent.Parent.ForceFieldOFF.Visible == false then
script.Parent.Parent.ForceFieldOFF.Visible = true
script.Parent.Parent.ForceFieldON.Visible = true
else
script.Parent.Parent.ForceFieldOFF.Visible = false
script.Parent.Parent.ForceFieldON.Visible = false
end
else return end
end
script.Parent.MouseButton1Click:connect(onClicked)

ForceFieldOFF[]

function onClicked(GUI)
script.Parent.Parent.ForceFieldOFF.Visible = false
script.Parent.Parent.ForceFieldON.Visible = false
f = script.Parent.Parent.Parent.Parent.Character:findFirstChild("ForceField")
if (f ~= nil) then
f:remove()
else return end
end
script.Parent.MouseButton1Click:connect(onClicked)

ForceFieldON[]

function onClicked(GUI)
script.Parent.Parent.ForceFieldOFF.Visible = false
script.Parent.Parent.ForceFieldON.Visible = false
h = script.Parent.Parent.Parent.Parent.Character:findFirstChild("Humanoid")
if (h ~= nil) then
FF = Instance.new("ForceField")
FF.Parent = script.Parent.Parent.Parent.Parent.Character
else return end
end
script.Parent.MouseButton1Click:connect(onClicked)

Great Job! You have completed the GUI!

To use this GUI:

Add your name to the first (VIP) script.

Click the ForceField button and press On or Off to turn your ForceField on or off.

Advertisement