I am a beginner scripted and I made an intermission script, and I got it to work, but when I tested it out it loaded my map multiple times and messed my game up. I am pretty sure that it is because I used a local script instead of a script, but I am not sure how to turn my code into something usable by a server script.
local Players = game:GetService("Players")
local tvalue = script.Parent.StatusTag
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local loadMapEvent = ReplicatedStorage:WaitForChild("LoadMapEvent")
local finishGameEvent = ReplicatedStorage:WaitForChild("FinishGameEvent")
function beginGame()
wait(1)
loadMapEvent:FireServer()
if game.Players.NumPlayers > 1 then
for i = 10, 0, -1 do
wait(1)
tvalue.Text = "Intermission: " .. i .. ""
if i == 0 then
tvalue.Text = "Game Started!"
local function teleAll(x, y, z)
local pos = Vector3.new(x, y, z)
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
plr.Character:MoveTo(pos)
end
end
end
wait(0.2)
teleAll(0, 3, 0)
end
end
else
tvalue.Text = "Need 2 or more players to begin."
end
end
beginGame()
finishGameEvent.OnClientEvent:Connect(beginGame)
