If statement is being ignored

hi i am making lobby system and when i check if the password is correct, it will add a player to the table, but it is just ignoring it

server script:

events.JoinPrivateLobby.OnServerEvent:Connect(function(plr)
	local lobbysFrames = plr.PlayerGui.GameGUI.GameFrame.LobbyFrame

	if lobbysFrames.PasswordPrompt.Password.Text == newLobby.Password.Value then
		table.insert(playerTable, plr.Name)
		print(playerTable)
	elseif lobbysFrames.PasswordPrompt.Password.Text ~= newLobby.Password.Value then
		print("invalid password")
	end
end)

local script:

script.Parent.MouseButton1Down:Connect(function()
	if script.Parent.Parent.Parent.isPrivate.Value == true then
		game.ReplicatedStorage.Events.JoinPrivateLobby:FireServer()
	end
end)

i appreciate any help

why not just use else? Its the exact same thing but shorter, and more convenient.

Remember that changes on the Client do not Replicate on the Server, so the Server will not the see the exact same text.

hmm, then how can i replicate text from a textbox to the server?

If you really wanted to, you can send the Data from the Client to the Server, using the RemoteEvent by adding another Parameter to it.

You cannot read what a client wrote in their GUI from the server, instead you have to send it through.

Change this into

game.ReplicatedStorage.Events.JoinPrivateLobby:FireServer(...Password.Text)

Then change inside the server event the following:

into

events.JoinPrivateLobby.OnServerEvent:Connect(function(plr, passwordText)

Then instead of using

replace it with passwordText.

yeah, i just did that, and you answered, lol, thanks anyways

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.