I know maps are supposed to be in the lighting section. So let’s say the game that I have has 3 maps. But the players are currently playing the game in 1 map which means that there is 2 more maps available to play. So my question is how do I make it so the game chooses a random map and teleports all the players into that map like every 10 minutes, but also into a random coordinate into that map so they don’t spawn close.
ROBLOX map changing every 10 minutes?
2 answers
You are asking too much without any source or code, but this is what i'd do, this code isnt tested, its suppose to give you a rough idea...
local maps = {game.ReplicatedStorage.Map1,game.replicatedStorage.Map2,game.replicatedStorage.Map3}
-- these are the maps ^
while true do wait()
for i = 600,1,-1 do
print('game time: '..i)
end
print('game ended')
-- assuming thats the 10 minutes game time ^
for i = 20,1,-1 do
print('intermission: '..i)
end
print('intermission ended')
local chosen = maps[math.random(1,#maps)]
local extents = chosen:GetSizeExtents()
local origin = chosen:GetSizeExtents().Magnitude/2
for _, v in pairs(game.Players:GetChildren()) do
local r1 = math.random(-math.abs(extents.X/2),math.abs(extents.X/2))
local r2 =10 -- make sure this is at the same level as your map...
local r3 = math.random(-math.abs(extents.Z/2),math.abs(extents.Z/2))
v.Character:SetPrimaryPartCFrame(CFrame.new(origin+Vector3.new(r1,r2+5,r3)))
for _, z in pairs(v.Character:GetChildren()) do
if #z:GetTouchingParts() > 0 then
end
end
end
print('game started')
end
I didn't test it because you didn't show much work, but if this helps you, id appreciate it if you click the answer button, thanks
So basically im assuming the beginning i is the game timer, once the game ends the intermission starts, then it chooses a map, gets the extents, divides the size of the whole map by 2, so x and z so u get the center. then I add a random distance away from the origin to get a random spawn point.
Lighting section? Are you talking about skyboxes, or maps? Do you mean physical maps? If you do, I can help you.
First of all, what were you thinking? If you want to store maps, I suggest putting them in a folder called "Maps" or something like that, in server storage.
https://gyazo.com/a6f0207f0013db4c906d9e2688a36578
Next, make a serverscript, and put in serverscriptservice. Then, insert this script template in:
local ServerStorage = game:GetService("ServerStorage")
local Maps = ServerStorage.Maps
while true do --Forever, unless you want it to be for limted time
local n = math.random(1, 3)
if n == 1 then
Maps.Map1.Parent = workspace
elseif n == 2 then
--same
else
--same
end
wait(600)
end
finally, edit the template to fit your custom needs.
This discussion is preserved as it was. New answers, comments, and votes are closed.
