Issue with my username gui

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to go to the next frame when the username you enter is right
  2. What is the issue? Include screenshots / videos if possible!
    I’m trying to make a username GUI that goes to the next frame if the player username is right that’s on the server but when I hit the enter button it prints out saying the username doesn’t exist when I enter the right username
    here’s my client script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local validateUsernameEvent = ReplicatedStorage:WaitForChild("ValidateUsernameEvent")

local textBox = script.Parent.Parent.Ordering.NameFrame.ImageLable:WaitForChild("TextBox")
local nextFrame = script.Parent:FindFirstChild("OrderFrame")
local continueButton = script.Parent.NameFrame.ImageLable:FindFirstChild("enter")


local function onValidationResult(success)
	if success then
		
		script.Parent.NameFrame.Visible = false 
		nextFrame.Visible = true 
	else
		
		print("Username not found!")
	end
end


local function validateUsername()
	local enteredUsername = textBox.Text
	validateUsernameEvent:FireServer(enteredUsername)
end


continueButton.MouseButton1Click:Connect(validateUsername)
validateUsernameEvent.OnClientEvent:Connect(onValidationResult)

and hers my server script

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local validateUsernameEvent = ReplicatedStorage:FindFirstChild("ValidateUsernameEvent")


local function validateUsername(player, enteredUsername)
	local targetPlayer = Players:FindFirstChild(enteredUsername)
	if targetPlayer then
		validateUsernameEvent:FireClient(player, true)
	else
		validateUsernameEvent:FireClient(player, false)
	end
end

validateUsernameEvent.OnServerEvent:Connect(validateUsername)

The problem is on the Client Script, What happens is that on validateUsername(),
you are making the variable set to textBox.Text, what happens with that is that the Text Property on the TextBox is What appears on default:
image
What would be this:
image

So to get the TextBox’s text, use the FocusLost() RBXScriptSignal to update it

Heres the edited code:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local validateUsernameEvent = ReplicatedStorage:WaitForChild("ValidateUsernameEvent")

local textBox = script.Parent.Parent.Ordering.NameFrame.ImageLable:WaitForChild("TextBox")
local nextFrame = script.Parent:FindFirstChild("OrderFrame")
local continueButton = script.Parent.NameFrame.ImageLable:FindFirstChild("enter")
local pressedEnter = false

local function onValidationResult(success)
	if success then

		script.Parent.NameFrame.Visible = false 
		nextFrame.Visible = true 
	else

		print("Username not found!")
	end
end

textBox.FocusLost:Connect(function(enterPressed)
	if enterPressed then --checks if it already pressed enter, otherwise it will return nil		
		pressedEnter = true
	end
end)

local function validateUsername()
	if not pressedEnter then return end
	local enteredUsername = textBox.Text
	validateUsernameEvent:FireServer(enteredUsername)
end


continueButton.MouseButton1Click:Connect(validateUsername)
validateUsernameEvent.OnClientEvent:Connect(onValidationResult)

this should work, otherwise let me know!

my name gui is still not working this time nothing prints out when I hit the enter button it does nothing

You are making sure to press enter when you’re done writing anything into the TextBox right?