For a Minigame I'm making, fog needs to show up, but it isn't working as intended. Here is the code I tried:
local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 0
while true do
local songNum = math.random(1,5)
game.Workspace.Songs.LobbySongs["Song"..songNum]:Play()
t = 11
repeat
t = t-1
s.Value = "Intermission: "..t
wait(1)
until t == 1
local plrs = game.Players:GetChildren()
local mapselect = game.ReplicatedStorage.Maps:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i = 1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
s.Value = "Minigame Chosen: "..curmap
end
end
wait(3)
t = 11
repeat
t = t-1
s.Value = "Teleporting players in "..t
wait(1)
until t == 1
game.Workspace.Songs.LobbySongs["Song"..songNum]:Stop()
workspace.Songs.LobbySongs.Song1.TimePosition = 30
workspace.Songs.GameSongs["The Sweeper"].TimePosition = 52
workspace.Songs.GameSongs["Kidnap Catastrophe"].TimePosition = 42
for i = 1,#plrs do
if workspace[curmap].Teleports ~= nil then
local num = math.random(1,10)
plrs[i].Character.Head.CFrame = CFrame.new(game.Workspace[curmap].Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
else
local num = math.random(1,10)
plrs[i].Character.Head.CFrame = CFrame.new(game.Workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
end
game.Workspace.Songs.GameSongs[curmap]:Play()
if curmap == "Flood Escape" then
t = 11
repeat
t = t-1
s.Value = "The cave will start flooding in "..t.." seconds; escape the cave!"
wait(1)
until t == 0
game.Workspace[curmap].MainScript.Disabled = false
game.Workspace[curmap].GameBarrier.CanCollide = false
repeat
s.Value = "The cave is flooding; escape the cave and avoid drowning!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until #plrs == 0
elseif curmap == "Escape Room" then
t = 11
repeat
t = t-1
s.Value = "The Escape will start in "..t.." seconds; be the first to escape the Factory!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 30
repeat
t = t-1
s.Value = "The Escape will end in "..t.." seconds; be the first to escape!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0 or vals.Winner.Value ~= ""
elseif curmap == "Trial of Terror" or curmap == "Trial of Terror 2" or curmap == "Trial of Terror 3" then
t = 11
repeat
t = t-1
s.Value = "The trial will begin in "..t.." seconds; press the buttons and reach the end!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 91
repeat
t = t-1
s.Value = "The trial will finish in "..t.." seconds; press the buttons & reach the end!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
s.Value = "Getting Winners..."
wait(1)
elseif curmap == "Flee the Field" then
t = 11
repeat
t = t-1
s.Value = "The challenge will start in "..t.." seconds; be the first to Flee the Field!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 60
repeat
t = t-1
s.Value = "The challenge ends in "..t.." seconds; be the first to Flee the Field!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0 or vals.Winner.Value ~= ""
elseif curmap == "Floor of Melting" then
t = 11
repeat
t = t-1
s.Value = "The Floor will vanish when you stand on it; don't fall into the pit and be the last player standing! The game starts in "..t.." seconds!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 60
repeat
t = t-1
s.Value = "The floor will vanish when you stand on it; be the last player player standing! The game ends in "..t.."seconds!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0 or vals.Winner.Value ~= ""
elseif curmap == "Hallways of Escape" then
t = 11
repeat
t = t-1
s.Value = "The Door will open in "..t.." seconds; be the first to escape the Mansion!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 41
repeat
t = t-1
s.Value = "The doors will lock in "..t.." seconds; be the first to escape!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0 or vals.Winner.Value ~= ""
elseif curmap == "High Peak Sprint" then
t = 11
repeat
t = t-1
s.Value = "The Sprint will start in "..t.." seconds; reach the Summit of the Mountain!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 60
repeat
t = t-1
s.Value = "The Sprint will finish in "..t.." seconds; reach the Summit of the Mountain!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
elseif curmap == "River Race" then
t = 11
repeat
t = t-1
s.Value = "The Race starts in "..t.." seconds; reach the other side of the River!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 60
repeat
t = t-1
s.Value = "The Race ends in "..t.." seconds; reach the other side of the River!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
elseif curmap == "Crumble Land" then
t = 11
repeat
t = t-1
wait(1)
s.Value = "The Island will start crumbling in "..t.." seconds; don't fall into the Pit!"
until t == 0
game.Workspace[curmap].MinigameMain.Disabled = false
t = 60
repeat
t = t-1
s.Value = "The Island will stop crumbling in "..t.." seconds; don't fall into the Pit!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
game.Workspace[curmap].WinPart.Script.Disabled = false
s.Value = "Getting Winners..."
wait(1)
elseif curmap == "Expedition Treasure-Find" then
t = 11
repeat
t = t-1
s.Value = "The Expedition will start in "..t.." seconds; be the first to find the Treasure!"
wait(1)
until t == 0
game.Workspace[curmap].GameBarrier.CanCollide = false
t = 30
repeat
t = t-1
s.Value = "The Expedition will finish in "..t.." seconds; be the first to find the Hidden Treasure!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0 or vals.Winner.Value ~= ""
elseif curmap == "The Sweeper" then
t = 11
repeat
t = t-1
wait(1)
s.Value = "The sweeper will start spinning in "..t.." seconds; don't get hit!"
until t == 0
game.Workspace[curmap].Spinner.RotationScript.Disabled = false
t = 31
repeat
t = t-1
s.Value = "The sweeper will stop spinning in "..t.." seconds; don't get hit!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
game.Workspace[curmap].WinPart.Script.Disabled = false
game.Workspace[curmap].Spinner.RotationScript.Disabled = true
s.Value = "Getting Winners..."
wait(1)
elseif curmap == "Maze of Murder" then
t = 10
repeat
t = t-1
s.Value = "The Murderer will start moving in "..t.." seconds; escape the Maze whilst avoiding being killed!"
wait(1)
until t == 0
t = 100
repeat
t = t-1
s.Value = "The Maze will collapse in "..t.." seconds; escape the Maze whilst avoiding being killed!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
elseif curmap == "Maze of Mirrors" then
t = 10
repeat
t = t-1
s.Value = "The Maze will open in "..t.." seconds; escape the Maze!"
wait(1)
until t == 0
workspace[curmap].Maze.GameBarrier.CanCollide = false
t = 60
repeat
t = t-1
s.Value = "The Maze will melt in "..t.." seconds; escape the Maze whilst avoiding being killed!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 0
elseif curmap == "Kidnap Catastrophe" then
t = 11
game.Lighting.FogStart = 250
repeat
t = t-1
s.Value = "A random player will be kidnapped in "..t.." seconds; be the first to find the kidnapped player!"
wait(1)
until t == 0
game.Workspace[curmap].Script.Disabled = false
game.Workspace[curmap].CageTree.Cage.Floor.Script.Disabled = false
t = 60
repeat
t = t-1
s.Value = "The Kidnapped player will be killed in "..t.." seconds; be the first to rescue them!"
wait(1)
local plrs = game.Workspace.Ingame:GetChildren()
until t == 0 or #plrs == 1 or vals.Winner.Value ~= ""
game.Lighting.FogStart = 100000
end
if vals.Winner.Value ~= "" then
s.Value = "Winner: "..vals.Winner.Value
else
s.Value = "Nobody won!"
end
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i = 1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
workspace[curmap]:Destroy()
game.Workspace.Songs.GameSongs[curmap]:Stop()
vals.Winner.Value = ""
workspace.Songs.LobbySongs.Song1.TimePosition = 30
workspace.Songs.GameSongs["The Sweeper"].TimePosition = 52
workspace.Songs.GameSongs["Kidnap Catastrophe"].TimePosition = 42
end
Don't worry about it all. All I need is help with lines 250 - 267.
Thanks!
-JBennettChief9
