Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What am I doing wrong with my holo script?

Asked by
Djinous 45
8 years ago

Okay, I have a training holo script that I wanted to change a little, and so I changed the keyvals that are said in the chat to load the map, and then I changed the name of the maps in the lighting to match the keyvals, but when I test it, the map will not load when I say the keyword combination "simulation initiate S-57" or any other map. What have I done wrong?

assert(workspace:FindFirstChild("Generator")~=nil,"There is no Generator model!")


gs = {}
trainers = {"Djinous"}

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)

game.Players.PlayerAdded:connect(function(player)
    if player:GetRankInGroup(567760) >= 161 then
        trainers[#trainers+1] = player.Name
    end
    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"]     = {}; 
   ["team"]   = {"ATK"};
    ["sword"]   = {"Sword"};
    ["gun"]     = {"Carbine"};
    ["both"]    = {"Sword", "Carbine-(30)"};
}

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(start)
    for _,v in pairs(game.Players:GetPlayers()) do
        resetTools(v)
        for key,val in pairs(envtools) do
            if string.lower(key) == string.lower(start) 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 start(Environment,Off)
    if not Off then
    newEnv = Instance.new("Model",workspace)
    newEnv.Name = Environment.Name 
    envTag = Instance.new("NumberValue",newEnv) 
    envTag.Name = "Environment"
        for _,v in pairs(Environment:GetChildren()) do
            if v:IsA("BasePart") then
            cframe = v.CFrame 
            newP = v:Clone()
            newP.Parent = newEnv
            newP.CFrame = cframe
            Select(newP,"Earth green")
            wait()
            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 = ""..string.upper(Environment.Name).." is finished. Enter when instructed." -- 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,"White")
            wait()
            v:Remove()
            end
        end
    wait(0.1)
    Environment:Remove()
    end
end


function onDoorSpeak(msg,recip) 

keywords = { 
    sample = {"simulation","terminate","initiate","F-88","O-21","O-62","S-57","F-43"};
}

keyvals = { 
    ["simulation"]              = false; 
    ["terminate"]                       = false;
    ["initiate"]                    = false;
    ["F-88"]                    = false;
    ["O-21"]                    = false;
    ["O-62"]                    = false;
    ["S-57"]                    = false;
    ["F-43"]                    = false;
}

    for _,v in pairs(keywords) do 
        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["simulation"] then 
        if keyvals["initiate"] then 
            if keyvals["F-88"] and not keyvals["O-21"] and not keyvals["O-62"] and not keyvals["S-57"] and not keyvals["F-43"]  then 
                if not checkEnv() then 
                start(game.Lighting["F-88"]) 
                loadTools("sword")
                end 
            elseif keyvals["O-21"] and not keyvals["F-88"] and not keyvals["O-62"] and not keyvals["S-57"] and not keyvals["F-43"]  then 
                if not checkEnv() then 
                start(game.Lighting["O-21"]) 
                loadTools("nil")
                end 
            elseif keyvals["O-62"] and not keyvals["F-88"] and not keyvals["O-21"] and not keyvals["S-57"] and not keyvals["F-43"]  then 
                if not checkEnv() then 
                start(game.Lighting["O-62"]) 
                loadTools("nil")
                end 
            elseif keyvals["S-57"] and not keyvals["O-21"] and not keyvals["O-62"] and not keyvals["F-88"] and not keyvals["F-43"]  then 
                if not checkEnv() then 
                start(game.Lighting["S-57"]) 
                loadTools("nil")
                end 
            elseif keyvals["F-43"] and not keyvals["O-21"] and not keyvals["O-62"] and not keyvals["S-57"] and not keyvals["F-88"]  then 
                if not checkEnv() then 
                start(game.Lighting["F-43"]) 
                loadTools("sword")
                end
                end
        elseif keyvals["terminate"] then
for i, player in pairs(game.Players:GetPlayers()) do
    player.Character.Torso.CFrame = CFrame.new(-17.1, 18.504, 92.101)
end
                for _,v in pairs(workspace:GetChildren()) do
                if v:FindFirstChild("Environment") then
                start(v,true) 
                loadTools("nil") 
                end
            end
        end
    end
end
0
One other thing, it will end a simulation and move everyone where it is supposed to, but it just won't load a map. Djinous 45 — 8y

Answer this question