Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 1 year ago
Edited 1 year ago

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)
0
What is the 'lobbies' variable? is it a table, folder, etc..? loowa_yawn 383 — 1y

1 answer

Log in to vote
2
Answered by
boredlake 256 Moderation Voter
1 year ago
Edited 1 year ago

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.

Ad

Answer this question