Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a map spawn at 0 players?

I want a map to spawn everytime a game ends or when the entire players team is empty. I tried to use this script...


local team = game.Teams.Players
local map = game.ReplicatedStorage.ParkMap

if team.??? = 0 then
	map:Clone(194, 37, 29.2)

2 comments

0

"team.??? = 0"? I think you should do "if #team.???:GetPlayers() = 0 then"

0

Also, instead of "map:Clone(194, 37, 29.2)", try "map:Clone() map:SetPrimaryPartCFrame(194, 37, 29.2)"

1 answer

✓ Accepted answer
  1. Syntax error here: if team.??? = 0 then. To check if a team is empty, you get the number of players and compare it with 0, like this: if #team:GetPlayers() == 0 then
  2. After cloning the model, its parent should be set to workspace (or a model in workspace) so that it would show up in game. Clone()d objects have their Parent property set to nil by default, and without a Parent, it really wouldn't show up anywhere.

Here's the solution:

local team = game.Teams.Players
local map = game.ReplicatedStorage.ParkMap

-- check if a team has 0 players
if #team:GetPlayers() == 0 then 
    -- clone the map, and put it in workspace
    map:Clone().Parent = workspace 
end

This discussion is preserved as it was. New answers, comments, and votes are closed.