Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

How Do I Make Map Spawns?

Asked by 9 years ago

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?

0
Seriously? Don't downvote me because I have no clue how to this... iiDitzy 5 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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

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). chess123mate 5873 — 9y
Ad

Answer this question