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 a basic login system?

What I've got on my game:

  • A button which says "Enter Code"
  • A GUI which should appear when you press the "Enter Code" button. It has a textbox and another button.
  • A second GUI which has 2 textboxes for ID and key, and a third button.

What I do want it to do:

  • If the first button is clicked, open the first GUI.
  • If value "123456" is entered in the first textbox AND the second button is clicked, close the first GUI and open the second GUI.
  • If value "39-932M" is entered in the "ID" textbox, value "mc83mxL" in the "Key" textbox, and the third button is pressed, display text "Success! Logging in..."

I do not know even where to start making it functional. Can someone PLEASE point me in the right direction if this forum hates spoonfeeding so much?

9 comments

0

This isn't a request site.

0

"boo hoo this isn't a request site" - How do I do this then?

0

@Ondrashek06, I suggest posting this on the developer forums.

0

[Edited: bullet points require a blank line before they start or else they don't appear.]

0

I am permanently banned from the devforums. I cannot post there.

0

I don't know why you're banned but you can search for an existing post, or make a new account and then post your question.

0

Ondrashek, you should consider reading rule #1.

0

How am I a jerk?

1 answer

✓ Accepted answer

A lot of what you're wanting is just logic, which I'll leave for you to figure out, but the knowledge you'll require will include:

  • Looking up what things are available in the API, such as here for the TextBox: https://developer.roblox.com/en-us/api-reference/class/TextBox - for example, for a TextBox you might want to know when they press "Enter" for a text box, or that to access the existing text you need the .Text property. If you look up TextButton (you can use the search bar at the top right of the API pages), the event you want is Activated, which triggers whenever someone clicks on it. In the API pages they often have examples that show you basic usage.
  • If you want to get fancy when screens appear/disappear you'll benefit from using the TweenService
  • If you don't have a good handle on how to listen to events, Roblox has a fair article on it: https://developer.roblox.com/en-us/articles/events
  • If you aren't familiar with Lua's syntax, you can find any tutorial online, or read the manual: https://www.lua.org/pil/contents.html - you probably don't need much syntax to do the basics, just what's shown on that Events tutorial page.
  • If by "login system" you just mean those values you mentioned (and no others), the process is much easier (as you just compare the text they entered to the values you're interested in), but if you want to have an account creation system for whatever reason, you'll need to keep track of information in data stores.

As you continue learning, you'll be able to ask more specific questions of your preferred search engine or here (but most questions of the form "How do I do [some basic thing in Lua/Roblox]?" have readily available answers).

One note, Roblox's article on events doesn't mention that you can use anonymous functions, which are fine if you don't need to call the function anywhere else. For example:

-- Their code:
local Players = game:GetService("Players")
 
local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		print(player.Name .. " spawned in: " .. character:GetFullName())
	end
	player.CharacterAdded:Connect(onCharacterAdded)
end
 
Players.PlayerAdded:Connect(onPlayerAdded)

-- Equivalent code with anonymous functions:
local Players = game:GetService("Players")
 
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		print(player.Name .. " spawned in: " .. character:GetFullName())
	end)
end)

Note that having an onPlayerAdded function (that isn't anonymous) is actually a good idea if you want to ensure that Roblox doesn't put your player into the server in Play Solo mode before your script has a chance to connect to the event - this doesn't happen online but can in testing; the work-around is this:

local Players = game:GetService("Players")
 
local function onPlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
		print(player.Name .. " spawned in: " .. character:GetFullName())
	end)
end 
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
	onPlayerAdded(player)
end

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