- assert(workspace:FindFirstChild("Generator")~=nil,"There is no Generator model!")
- --Instructors are in marks throughout the script
- trainers = {"dudiebum10","Lordofsmartness","jasontor1000","Maculus","YaYaBinks3"}
- gs = {} -- If you have a script in your environment, put the name in here
- --[[For the Generator:
- - Have a Model in the workspace named Generator
- - In this, have a brick named Torso
- - Also have a humanoid
- - Run this in the Command Bar: (After completing the first 3 bulletpoints)
- select = Instance.new("SelectionPartLasso",workspace.Generator) select.Name = "Connection" select.Humanoid = select.Parent.Humanoid
- ]]
- function globalScript(s)
- yes = false
- for i = 1,#gs do
- if s.Name == gs[i] then
- yes = true
- break
- end
- end
- return yes
- end
- game.Players.PlayerAdded:connect(function(player)
- for i=1,#trainers do
- if trainers[i]==player.Name then
- player.Chatted:connect(onDoorSpeak)
- break
- end
- end
- end)
- function checkEnv()
- yes = false
- for _,v in pairs(workspace:GetChildren()) do
- if v:FindFirstChild("Environment") then
- yes = true
- end
- end
- return yes
- end
- envtools = {
- ["nil"] = {}; -- Keep this. It is required for the command to work properly
- ["winter"] = {"Rifle"};
- ["arena"] = {"Rifle", "Sniper"};
- ["cs"] = {};
- ["combat"] = {"Rifle","Sword"};
- ["boss"] = {"Rifle"};
- ["cave"] = {"Sword"};
- ["water fight"] = {"Sword","Rifle","Sniper"};
- ["bunker"] = {"Sniper"};
- ["bunker"] = {"Sniper"};
- ["tower"] = {"Sword", "Rifle"};
- ["test"] = {"Sword"};
- }
- tloc = {"Backpack","StarterGear"}
- function resetTools(Player)
- for _,btool in pairs(Player.Backpack:GetChildren()) do
- btool:Remove()
- end
- for _,stool in pairs(Player.StarterGear:GetChildren()) do
- stool:Remove()
- end
- end
- function loadTools(Program)
- for _,v in pairs(game.Players:GetPlayers()) do
- resetTools(v)
- for key,val in pairs(envtools) do
- if string.lower(key) == string.lower(Program) then
- for _,tool in pairs(val) do
- if game.Lighting:FindFirstChild(tool) then
- local t = game.Lighting:FindFirstChild(tool)
- for i = 1,#tloc do
- t:Clone().Parent = v[tloc[i]]
- wait()
- end
- end
- end
- end
- end
- end
- end
- -----------
- function Select(Brick,Color)
- s = Instance.new("SelectionBox",Brick)
- s.Color = BrickColor.new(Color)
- s.Adornee = Brick
- workspace.Generator.Connection.Part = Brick
- workspace.Generator.Connection.Color = BrickColor.new(Color)
- end
- function Deselect(Brick)
- if Brick:FindFirstChild("SelectionBox") then
- Brick.SelectionBox:Remove()
- end
- workspace.Generator.Connection.Part = nil
- end
- function Program(Environment,Off)
- if not Off then
- newEnv = Instance.new("Model",workspace) -- Why create a new model instead of copying it?
- newEnv.Name = Environment.Name -- Copying individual bricks causes less lag than copying a bunch at one time
- envTag = Instance.new("NumberValue",newEnv) -- Plus this allows us to have the bricks interrupting other models
- envTag.Name = "Environment"
- for _,v in pairs(Environment:GetChildren()) do
- if v:IsA("BasePart") then
- cframe = v.CFrame -- Our part's position (As a CFrame :3)
- newP = v:Clone()
- newP.Parent = newEnv
- newP.CFrame = cframe
- Select(newP,"Bright blue")
- wait()
- if newP:FindFirstChild("Transparent") then -- Some bricks need custom transparency (Default is 0)
- newP.Transparency = newP:FindFirstChild("Transparent").Value
- else
- newP.Transparency = 0 -- Default transparency (0)
- end
- Deselect(newP)
- elseif v:IsA("Script") then
- if globalScript(v) then
- newS = v:Clone()
- newS.Parent = newEnv
- end
- end
- end
- m = Instance.new("Message",workspace)
- m.Text = "Creation of "..string.upper(Environment.Name).." Is finished please enter when ready." -- Edit this to whatever you want, or remove it
- wait(5)
- m:Remove()
- elseif Off then
- for _,v in pairs(Environment:GetChildren()) do
- if v:IsA("BasePart") then
- Select(v,"Bright red")
- wait()
- v:Remove()
- end
- end
- wait(0.1)
- Environment:Remove()
- end
- end
- function onDoorSpeak(msg,recip) -- The main speaking function (Originally this was intended only for doors; hence "onDoorSpeak")
- keywords = { -- Table filled with keywords
- sample = {"Test", "computer","begin","end","courtney starling","program","combat","winter fight","arena","boss fight","armoury","cave","water fight","bunker","meeting","tower"};
- }
- keyvals = { -- Values to tell us if we said them or not
- ["computer"] = false; -- The key of these variables must be the same as the corresponding value of keywords
- ["begin"] = false;
- ["end"] = false;
- ["courtney starling"] = false;
- ["program"] = false;
- ["combat"] = false;
- ["winter fight"] = false;
- ["arena"] = false;
- ["boss fight"] = false;
- ["armoury"] = false;
- ["cave"] = false;
- ["water fight"] = false;
- ["bunker"] = false;
- ["meeting"] = false;
- ["tower"] = false;
- ["test"] = false;
- }
- for _,v in pairs(keywords) do -- This little bit here tells us what was said
- for i = 1,#v do
- s,e=string.lower(msg):find(v[i])
- if s ~= nil and e ~= nil then
- if s == e-(v[i]:len()-1) then
- keyvals[v[i]]=true
- end
- end
- end
- end
- wait()
- if keyvals["computer"] then -- Base loop, make sure we said "computer" (Or whatever word you want to need for every command)
- if keyvals["program"] and keyvals["begin"] then -- Program loop
- if keyvals["courtney starling"] and not keyvals["winter fight"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["armoury"] then -- Finally, specific program name :3
- if not checkEnv() then -- Make sure there's not already a program running
- Program(game.Lighting["Courtney Starling"]) -- The function that controls everything
- loadTools("cs")
- end
- elseif keyvals["winter fight"] and not keyvals["combat"] and not keyvals["courtney starling"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["cave"] and not keyvals["meeting"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Winter Fight"])
- loadTools("winter")
- end
- elseif keyvals["combat"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["cave"] and not keyvals["meeting"] and not keyvals["water fight"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Combat"])
- loadTools("combat")
- end
- elseif keyvals["arena"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["cave"] and not keyvals["meeting"] and not keyvals["water fight"] and not keyvals["bunker"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Arena"])
- loadTools("arena")
- end
- elseif keyvals["boss fight"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["armoury"] and not keyvals["cave"] and not keyvals["meeting"] and not keyvals["water fight"] and not keyvals["bunker"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Boss Fight"])
- loadTools("boss")
- end
- elseif keyvals["armoury"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["cave"] and not keyvals["meeting"] and not keyvals["water fight"] and not keyvals["bunker"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Armoury"])
- loadTools("boss")
- end
- elseif keyvals["cave"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["meeting"] and not keyvals["water fight"] and not keyvals["bunker"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Cave"])
- loadTools("cave")
- end
- elseif keyvals["water fight"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["meeting"] and not keyvals["cave"] and not keyvals["bunker"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Water Fight"])
- loadTools("water fight")
- end
- elseif keyvals["bunker"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["meeting"] and not keyvals["cave"] and not keyvals["water fight"] and not keyvals["tower"] then
- if not checkEnv() then
- Program(game.Lighting["Bunker"])
- loadTools("bunker")
- end
- elseif keyvals["meeting"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["bunker"] and not keyvals["cave"] and not keyvals["tower"] and not keyvals["water fight"] then
- if not checkEnv() then
- Program(game.Lighting["Meeting"])
- loadTools("meeting")
- end
- elseif keyvals["tower"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["bunker"] and not keyvals["cave"] and not keyvals["water fight"] and not keyvals["meeting"] then
- if not checkEnv() then
- Program(game.Lighting["Tower"])
- loadTools("tower")
- end
- elseif keyvals["test"] and not keyvals ["tower"] and not keyvals["winter fight"] and not keyvals["courtney starling"] and not keyvals["combat"] and not keyvals["arena"] and not keyvals["boss fight"] and not keyvals["armoury"] and not keyvals["bunker"] and not keyvals["cave"] and not keyvals["water fight"] and not keyvals["meeting"] then
- if not checkEnv() then
- Program(game.Lighting["Stasis"])
- loadTools("test")
- end
- end
- elseif keyvals["program"] and keyvals["end"] then
- for _,v in pairs(workspace:GetChildren()) do
- if v:FindFirstChild("Environment") then
- Program(v,true) -- The second argument is "Off", which tells the script whether we're creating or removing a program
- loadTools("nil")
- end
- end
- end
- end
- end