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

How Do I Make Map Spawns?

What I mean by this is, how do I make map for a game, create map spawns, and have all the players teleport to one. (Some might teleport to the same one, but no biggy.) I tried using CFrame ( numbers) or CFrame (numbers) to teleport to 2 different spawn points, but no luck there. Could someone please help me in this situation?

1 comment

0

Seriously? Don't downvote me because I have no clue how to this...

1 answer

✓ Accepted answer

Well what I would do is go through the map which I assume is inside workspace named 'Map' in this example #In a script

local Spawns={}
function loop(pi)
for _,s in next,pi:GetChildren() do
if s:IsA("SpawnLocation") then
table.Insert(Spawns,s)
elseif s:GetChildren~=nil then
loop(s)
end
end
end

function SpawnPlayers()
for _,pl in next,game.Players:GetChildren()
local ch=math.random(#Spawns)
if ch~=0 then
pl.RespawnLocation=Spawns[ch]
pl:LoadCharacter()
end
end
end

Please rep me up if you like this post and I wrote this on my phone Btw :D

1 comment

0

Line 6: s:GetChildren~=nil should be #s:GetChildren()>0, but even that's unnecessary, since "loop" won't do anything if there are no children (so I'm recommending that you end the if at line 6 and let it loop regardless).

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