Basically, Idea is, when players touch a script, Players should get inserted to a table that is on a Module Script:

ServerScriptStorage

local playersInRoomOne = require(game.ReplicatedStorage.ModuleScript)
game.Workspace.SpawnLocation.Touched:Connect(function(hit)
    playersInRoomOne.InsertPlayersInTheTable(hit.Parent)

Module Script

local playersInRoom = {}


function playersInRoom.InsertPlayersInTheTable(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        table.insert(playersInRoom, hit.Parent)
        print(table.concat(playersInRoom, ", "))
        end
    end

return playersInRoom

4 comments

0

You can't use table.concat() for an Objects(in this case is the Character). It only work for string and number https://developer.roblox.com/en-us/api-reference/lua-docs/table

0

So maybe hit.Parent.Name will work, it will return Character Model is name(which is a string)

0

I won't be able to use Studio for some time, if I do Name would work yeah?

0

It will work, checked it.