I'm making a round script for my friend's game, and I'd like there to be a cutscene once the map loads. The map, once loaded, is in a folder in workspace. When not loaded, it's in a folder in ReplicatedStorage.
Each map has a specific cutscene, but how would I make that specific cutscene play once the random map is loaded? Here's what I've tried so far:
--Round Variables
local timeint = 250
local introundtime = 5
local inttime = 1
local title = game.StarterGui:WaitForChild("Main").Top.Title
--Round Objects
local status = game.ReplicatedStorage:WaitForChild("Status")
local statusTransparency = status.Parent.statusTransparency
local mapChosen = status.Parent.mapChosen
local mapFolder = status.Parent.Maps
local maps = mapFolder:GetChildren()
local choices = {}
--Functions
wait()
fadeIn = function()
for t = 1, 0, -0.1 do
wait(0.05)
statusTransparency.Value = t
print(t)
end
end
fadeOut = function()
for t = 0, 1, 0.1 do
wait(0.05)
statusTransparency.Value = t
print(t)
end
end
--Main
--while wait() do
--while game.Players.NumPlayers < 2 do
--status.Value = 'There need to be 2 or more players to begin'
--repeat wait(2) until game.Players.NumPlayers >= 2
--end
for i = inttime, 0, -1 do
if i == 1 then
wait(1)
status.Value = "Intermission: "..i.." second"
else
wait(1)
status.Value = "Intermission: "..i.." seconds"
end
end
wait(1.5)
fadeOut()
wait(2)
status.Value = "Choosing the map..."
fadeIn()
--Choose Map
function chooseMap()
for i = 1, #maps do
if maps[i]:isA("Model") then
table.insert(choices,maps[i])
end
end
local picked = math.random(1, #maps)
mapChosen.Value = choices[picked].Name
end
function loadMap()
local map = game.ReplicatedStorage.Maps:FindFirstChild(mapChosen.Value)
clone = map:Clone()
clone.Parent = workspace.CurrentMap
end
chooseMap()
loadMap()
wait(4)
status.Value = "Map Chosen: "..mapChosen.Value
wait(1)
clone.Cutscene.Disabled = false
fadeOut()
local fadeInCoroutine = coroutine.create(function()
wait(1)
fadeIn()
end)
local forCoroutine = coroutine.create(function()
for i = timeint, 1, -1 do
wait(1)
status.Value = "Game: "..i.." seconds"
end
end)
coroutine.resume(fadeInCoroutine)
coroutine.resume(forCoroutine)
wait(2.5)
--end
Thanks!
