So whats going on here is I wanted two things to happen in one script by combining two tutorials one would spawn the map the other would teleport players but when I mixed the scripts it changed nothing
The Tutorials
The Code
local maps = game:GetService(“ServerStorage”):WaitForChild(“maps”)
local toAnnounce = game:GetService(“ReplicatedStorage”):WaitForChild(“toAnnounce”)
local gameModule = require(script:WaitForChild(“gameModule”))
local Game = game.Workspace.Game.Position
local minPlayers = 1
function clear()
toAnnounce.Value = “”
end
function announce(txt, duration)
toAnnounce.Value = txt
if duration ~= nil then
wait(duration)
clear()
end
end
function countdown(num, prefix)
for i = 0, num do
wait(1)
if prefix then
announce(prefix … num - i)
else
announce(num - i)
end
end
end
function startRound()
while #game:GetService("Players"):GetChildren() < minPlayers do
announce(minPlayers .. " players are required to play...")
wait(1)
end
wait(1)
countdown(3, "Round begins in... ")
local rand = math.random(1, #maps:GetChildren())
local allPlaces = maps:GetChildren()
local place = allPlaces[rand]
announce("Map chosen: " .. place.Name)
place.Parent = workspace
wait(3)
announce("Let the games begin!", 1)
gameModule.run(place)
local teleport = game.Players:GetChildren()
for i = 1, #teleport do
teleport[i]:LoadCharacter()
end
countdown(3)
place.Parent = maps
end
– – – > PLAYER JOINS GAME
wait(5)
while true do
startRound()
end
normal script 1
local maps = game:GetService(“ServerStorage”):WaitForChild(“maps”)
local toAnnounce = game:GetService(“ReplicatedStorage”):WaitForChild(“toAnnounce”)
local gameModule = require(script:WaitForChild(“gameModule”))
local minPlayers = 1
function clear()
toAnnounce.Value = “”
end
function announce(txt, duration)
toAnnounce.Value = txt
if duration ~= nil then
wait(duration)
clear()
end
end
function countdown(num, prefix)
for i = 0, num do
wait(1)
if prefix then
announce(prefix … num - i)
else
announce(num - i)
end
end
end
function startRound()
while #game:GetService("Players"):GetChildren() < minPlayers do
announce(minPlayers .. " players are required to play...")
wait(1)
end
wait(1)
countdown(3, "Round begins in... ")
local rand = math.random(1, #maps:GetChildren())
local allPlaces = maps:GetChildren()
local place = allPlaces[rand]
announce("Map chosen: " .. place.Name)
place.Parent = workspace
wait(3)
announce("Let the games begin!", 1)
gameModule.run(place)
countdown(3)
place.Parent = maps
end
– – – > PLAYER JOINS GAME
wait(5)
while true do
startRound()
end
Normal Script 2 (not the main script)
local seconds = game.Workspace.Time
local ingame = game.Workspace.InGame.Value
local Game = game.Workspace.Game.Position
while true do
wait(1)
seconds.Value = seconds.Value - 1
if seconds.Value == 0 and ingame == 0 then
ingame = 1
seconds.Value = 20
local teleport = game.Players:GetChildren()
for i = 1, #teleport do
teleport[i].Character:MoveTo(Vector3.new(Game.X, Game.Y, Game.Z))
end
end
if seconds.Value == 0 and ingame == 1 then
ingame = 0
seconds.Value = 15
local teleport = game.Players:GetChildren()
for i = 1, #teleport do
teleport[i]:LoadCharacter()
end
end
end
oh and the module script
(which is in the main script)
module script
local gameModule = {}
local function run(place)
print(place)
end
return gameModule
I also have a save data script but I don’t think that’s very important
there is a object named game to have the teleport too
Thanks For Your Time.
P.S. maps is in server storage
