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

Getting table entry by number returning nil?

Asked by 4 years ago
Edited 4 years ago

Prints: 0

Error: 14:28:30.952 - ServerScriptService.ServerMain:287: attempt to index nil with 'GameMode'

spawn(function()
    local TotalMapChoices = 1
    local GameSetups = {
        Testing = {
            GameMode = "1v1v1";
            Map = "Testing";
            PlaceId = 5118456383
        };
    }
    while true do
        if game.ReplicatedStorage.Slots.One.Status.Value == "Empty" then
            game.ReplicatedStorage.Slots.One.Status.Value = "Setup"
            print(#GameSetups)
            local ChosenMapNumber = math.random(1,TotalMapChoices)
            local ChosenMap = GameSetups[ChosenMapNumber]
            game.ReplicatedStorage.Slots.One.GameMode.Value = ChosenMap.GameMode
            game.ReplicatedStorage.Slots.One.Map.Value = ChosenMap.Map
            game.ReplicatedStorage.Slots.One.PlaceId.Value = ChosenMap.PlaceId
            game.ReplicatedStorage.Slots.One.Status.Value = "Ready"
        end
        if game.ReplicatedStorage.Slots.Two.Status.Value == "Empty" then
            game.ReplicatedStorage.Slots.Two.Status.Value = "Setup"
            local ChosenMap = math.random(1,TotalMapChoices)
            ChosenMap = GameSetups[ChosenMap]
            game.ReplicatedStorage.Slots.Two.GameMode.Value = ChosenMap.GameMode
            game.ReplicatedStorage.Slots.Two.Map.Value = ChosenMap.Map
            game.ReplicatedStorage.Slots.Two.PlaceId.Value = ChosenMap.PlaceId
            game.ReplicatedStorage.Slots.Two.Status.Value = "Ready"
        end
        if game.ReplicatedStorage.Slots.Three.Status.Value == "Empty" then
            game.ReplicatedStorage.Slots.Three.Status.Value = "Setup"
            local ChosenMap = math.random(1,TotalMapChoices)
            ChosenMap = GameSetups[ChosenMap]
            game.ReplicatedStorage.Slots.Three.GameMode.Value = ChosenMap.GameMode
            game.ReplicatedStorage.Slots.Three.Map.Value = ChosenMap.Map
            game.ReplicatedStorage.Slots.Three.PlaceId.Value = ChosenMap.PlaceId
            game.ReplicatedStorage.Slots.Three.Status.Value = "Ready"
        end
        if game.ReplicatedStorage.Slots.Four.Status.Value == "Empty" then
            game.ReplicatedStorage.Slots.Four.Status.Value = "Setup"
            local ChosenMap = math.random(1,TotalMapChoices)
            ChosenMap = GameSetups[ChosenMap]
            game.ReplicatedStorage.Slots.Four.GameMode.Value = ChosenMap.GameMode
            game.ReplicatedStorage.Slots.Four.Map.Value = ChosenMap.Map
            game.ReplicatedStorage.Slots.Four.PlaceId.Value = ChosenMap.PlaceId
            game.ReplicatedStorage.Slots.Four.Status.Value = "Ready"
        end
        wait(10)
    end
end)

Answer this question