So I made a monster that spawns and the monster will not count as a player, otherwise the game will never end. But I cannot figure out how to do it. Can someone help? Here's my error: 20:14:09.658 - ServerScriptService.Script:61: bad argument #1 to 'remove' (table expected, got Object)
And here's the script where the error came from.
local status = game.ReplicatedStorage.status
local timer = game.ReplicatedStorage.timer
local plrsLeft = game.ReplicatedStorage.plrs
local gameTime = 70
local intermission = 20
local maps = game.ServerStorage.Maps
local id = game.ReplicatedStorage.ImageId
while true do
status.Value = "Waiting for more players."
plrsLeft.Value = "0/".. game.Players.NumPlayers
repeat wait(1) until game.Players.NumPlayers >= 1
for i = intermission,0,-1 do
status.Value = "Intermission"
id.Value = "http://www.roblox.com/asset/?id=4546507417"
local minutes = math.floor(i/60)
local seconds = math.floor(i%60)
timer.Value = (string.format("%i:%.2i", minutes, seconds))
wait(1)
local plrs = {}
for e, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player)
if i == 0 then
status.Value = "Generating map."
wait(2)
local availableMaps = maps:GetChildren()
local chosenMap = availableMaps[math.random(1,#availableMaps)]
local clonedMap = chosenMap:Clone()
clonedMap.Parent = game.Workspace
wait(1)
status.Value = clonedMap.Name.." loaded, get ready."
wait(2)
local spawns = clonedMap:FindFirstChild("SpawnPoints")
local availableSpawns = spawns:GetChildren()
local character = player.Character
plrsLeft.Value = #plrs.."/".. game.Players.NumPlayers
character.HumanoidRootPart.CFrame = availableSpawns[1].CFrame
table.remove(availableSpawns,1)
for x = gameTime,0,-1 do
id.Value = "http://www.roblox.com/asset/?id=4546507994"
local minutes = math.floor(x/60)
local seconds = math.floor(x%60)
timer.Value = (string.format("%i:%.2i", minutes, seconds))
wait(1)
status.Value = "Game in progress."
character.Humanoid.Died:Connect(function()
table.remove(plrs,player)
print(player.Name.." has died/left the game.")
end)
if x <= 20 then
id.Value = "http://www.roblox.com/asset/?id=4546508680"
end
--// Pick a player to be monster ;)
local num = math.random(1,#plrs)
plrs[num].Character = game.ServerStorage.Telamon
game.ServerStorage.Telamon.Parent = workspace
wait(0.000000000000025)
workspace:FindFirstChild("Telamon").HumanoidRootPart.CFrame = clonedMap.MonsterSpawn.CFrame
table.remove(plrs[num],player)
if plrs[num] == 1 and #plrs == 0 then
status.Value = "Telamon wins."
plrs[num].leaderstats.Coins.Value = plrs[num].leaderstats.Coins.Value + 100
wait(1)
break
elseif x == 0 then
status.Value = "Time out."
wait(1)
break
elseif plrs[num] == nil then
status.Value = "Telamon left."
wait(1)
break
end
player:LoadCharacter()
clonedMap:Destroy()
status.Value = "Gamer over."
plrsLeft.Value = "0/".. game.Players.NumPlayers
timer.Value = 0
wait(2)
end
player:LoadCharacter()
break
end
end
end
end
end

1 comment
does the table conatain Player Objects, or characters?