#im confused [SOLVED]

1 messages · Page 1 of 1 (latest)

lilac jacinth
#

in the message below this is the server-side for a mafia game im making. im trying to get the basic functionality of a role randomizer to work, but for some weird ass reason the queuedPlayers table isnt getting passed through

#
--SERVICES
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local Role = ReplicatedStorage.Role

--MODULES
local MafiaGame = require(ReplicatedStorage.MafiaGame)
--local Villager = require(Role.Villager)
--local Mafia = require(Role.Mafia)
local Player = require(ReplicatedStorage.Player)
--REMOTES
--local GameStart = ReplicatedStorage.Core.Remotes:WaitForChild("GameStart")

local Round = require(ServerScriptService.Round)

local newRound = Round.new()

local currentGame = nil

local queuedPlayers = {}
--if not game:IsLoaded() then
--    game.Loaded:Wait()
--end

function Main()
    while not newRound.inRound do
        task.wait()
    end
    
    currentGame = MafiaGame.new(queuedPlayers)
    currentGame.Start()
end

Players.PlayerAdded:Connect(function(p)
    print("connected function is running")
    table.insert(queuedPlayers, Player.new(p.DisplayName, p.UserId))
    if newRound.Status == "Intermission" then return end
    if not newRound.inRound then
        newRound:Init()
    end
end)


Players.PlayerRemoving:Connect(function(p)
    if not newRound.inRound then
        for _,v in queuedPlayers do
            if v.userID == p.UserId then
                table.remove(queuedPlayers, v)
                print("removed" .. p.DisplayName .. "from queue")
            end
        end
    else
        --TODO: handle player leaving during round (make em dead ingame, add penalty later)
    end
end)




Main()
bold mulch
#

whats suppose to be the question

lilac jacinth
safe mulchBOT
#

studio** You are now Level 6! **studio

lilac jacinth
#

it feels like table.insert is just not operating how i want it to

#

that or im fucking something major up somewhere

topaz olive
#

the type and typeof functions return a string. always watch your output window, and look up things in the docs even if they are seemingly trivial as the type() or assert() functions

lilac jacinth
#

is there an alternative to ensure that a table is getting passed

lilac jacinth
#

oh god damn it i didnt use typeof

#

my stupid ass used type

topaz olive
#

you're welcome fingerguns

lilac jacinth
lilac jacinth
#

yesssss