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

What am I doing wrong with the position?

So you guys may know that I have been working on a login system. So far the script works but I can't position the textboxes and buttons in the right place. I have tried many methods so far but they keep appearing in the upper-left hand corner. IT would be much delighted if you guys could help :)

Here is the script-

local Username = {"x","x","x","x","x"}
Username[1] = "x"
Username[2] = "x"
Username[3] = "x"
Username[4] = "x"
Username[5] = "x"
local Password = {"x","x","x","x","x"}
Password[1] = "x"
Password[2] = "x"
Password[3] = "x"
Password[4] = "x"
Password[5] = "x"

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui

local textbox1 = Instance.new("TextBox")
textbox1.Parent = screen
textbox1.Text = "Username"
textbox1.Size = UDim2.new(0.25,0.0,0.25,0.0)
textbox1.Position = UDim2.new(0.0,0.3,0.0)
textbox1.FontSize = Enum.FontSize.Size14
textbox1.Font = Enum.Font.SourceSansLight
textbox1.Visible = true
textbox1.Selectable = true

local textbox2 = Instance.new("TextBox")
textbox2.Parent = screen
textbox2.Text = "Password"
textbox2.Size = UDim2.new(0.25,0.0,0.25,0.0)
textbox2.Position = UDim2.new(0.0,0.55,0.0)
textbox2.FontSize = Enum.FontSize.Size14
textbox2.Font = Enum.Font.SourceSansLight
textbox2.Visible = true
textbox2.Selectable = true

local textbox3 = Instance.new("TextBox")
textbox3.Parent = screen
textbox3.Text = "Your information submitted it incorrect, please start over or make an account. Thank you"
textbox3.Size = UDim2.new(0.75,0.0,0.75,0.0)
textbox3.Position = UDim2.new(0.0,0.0,0.0)
textbox3.FontSize = Enum.FontSize.Size18
textbox3.Font = Enum.Font.SourceSansBold
textbox3.Visible = false

local textbutton = Instance.new("TextButton")
textbutton.Text = "Submitt"
textbutton.Size = UDim2.new(0.25,0.0,0.25,0.0)
textbutton.Position = UDim2.new(0.0,0.8,0.0)
textbutton.FontSize = Enum.FontSize.Size14
textbutton.Font = Enum.Font.SourceSansLight
textbutton.Visible = true


local function check()
	local find1 = Username:FindFirstChild(textbox1.Text)
	local find2 = Password:FindFirstChild(textbox2.Text)
	if find1 and find2 then
		textbox1:Destroy()
		textbox2:Destroy()
	end
	local found = false
	for i = 1,#Username do
		if textbox1.Text and textbox2.Text == textbox1.Text == Username[i] and textbox2.Text == Password[i]then
			textbox1:Destroy()
			textbox2:Destroy()
				found = true
			break
		end
	end
	if found then 
		textbox3.Destroy()
		wait(5)
		textbox3.Visible = true
		wait(5)
		textbox3:Destroy()
	end
end
textbutton.MouseButton1Down:connect("functionName")

Thanks again, Sammy52520

1 comment

0

Every time you set the position, you're giving UDim2.new 3 arguments instead of 4.

1 answer

For some reason you're creating the size properly, but not the position UDim2. Like the comment mentioned, UDim2 takes 4 arguments.

local position = UDim2.new( xScale, xOffset, yScale, yOffset )

Where xScale and yScale is the absolute position in range of 0-1. And where xOffset and yOffset is position in pixels, which will always be a natural number(whole and greater or equal than 0).

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