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

If statements says values aren't equal while they are?

I'm creating a lobby system, I want to check if the player if the host if so then we'll remove the entire lobby. While I'm the host it doesn't say so?

Output

events.LeaveLobby.OnServerInvoke = (function(player, id)
	if lobbies[id] then
		print(lobbies[id].Host) -- Prints Omar_Hopman
		print(player.Name) -- Prints Omar_Hopman
		local host = lobbies[id].Host
		local playername = player.Name
		
		if playername == host then
			print("Player is host deleting lobby")

			table.remove(lobbies, id)
			events.UpdateLobbies:InvokeClient()
		elseif playername ~= host then
			print("Player is not host removing player")

			table.remove(lobbies[id].Players, table.find(lobbies[id].Players, player.Name))
			
			for i, p in ipairs(game.Players:GetChildren()) do
				events.UpdateLobbies:InvokeClient(p, lobbies)
			end
		end
	else
		warn("Lobby not found with ID " .. id)
	end
	print(lobbies)
end)

1 comment

0

What is the 'lobbies' variable? is it a table, folder, etc..?

1 answer

In line 05, is lobbies[id].Host an Instance (an object that can be seen in the Workspace), or is it a StringValue? If it's an Instance, try lobbies[id].Host.Name to make it a string.

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