trainers = {""}
groupid = 947529
game.Players.PlayerAdded:connect(function(player)
if player:GetRankInGroup(groupid) >= 9 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
function onDoorSpeak(msg,recip)
keywords = {
sample = {"computer","end","start","sft","abominable","awards","randomteams","resetteams","hillyholes"};
}
keyvals = {
["computer"] = false;
["end"] = false;
["start"] = false;
["sft"] = false;
["abominable"] = false;
["awards"] = false;
["randomteams"] = false;
["resetteams"] = false;
["hillyholes"] = 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["computer"] then
msg = Instance.new("Message",game.Workspace)
if keyvals["start"] then
if keyvals["sft"] then
if not checkEnv() then
clone = game.Lighting.Simulations.SFT:Clone()
clone.Parent = game.Workspace
clone.Name = "Environment"
msg.Text = "SFT loaded."
wait(1)
msg:Destroy()
end
elseif keyvals["abominable"] then
if not checkEnv() then
clone1 = game.Lighting.Simulations.Abominable:Clone()
clone1.Parent = game.Workspace
clone1.Name = "Environment"
msg.Text = "Abominable loaded."
wait(1)
msg:Destroy()
end
elseif keyvals["awards"] then
if not checkEnv() then
clone2 = game.Lighting.Simulations.Awards:Clone()
clone2.Parent = game.Workspace
clone2.Name = "Environment"
msg.Text = "Awards loaded."
wait(1)
msg:Destroy()
end
elseif keyvals["hillyholes"] then
if not checkEnv() then
clone3 = game.Lighting.Simulations.HillyHoles:Clone()
clone3.Parent = game.Workspace
clone3.Name = "Environment"
msg.Text = "Hilly Holes loaded."
wait(1)
msg:Destroy()
end
end
elseif keyvals["end"] then
if game.Workspace.Environment ~= nil then
game.Workspace.Environment:Destroy()
msg.Text = "Current sim removed."
wait(1)
msg:Destroy()
end
elseif keyvals["randomteams"] then
msg.Text = "Randomizing teams..."
a = game.Players:GetChildren()
blueteam = 0
greenteam = 0
for i,v in pairs(a) do --start for loop
if v.TeamColor == BrickColor.new("Bright yellow") or BrickColor.new("Bright violet") then
if blueteam >= greenteam then --check for unbalanced teams
v.TeamColor = BrickColor.new("Really blue")
blueteam = blueteam + 1
elseif greenteam > blueteam then --check for unbalanced teams
v.TeamColor = BrickColor.new("Lime green")
greenteam = greenteam + 1
end --end if teams are unbalanced
elseif v.TeamColor == BrickColor.new("Really blue") then --check for blue players
blueteam = blueteam + 1
elseif b.TeamColor == BrickColor.new("Lime green") then --check for green players
greenteam = greenteam + 1
end
end --end for loop
wait(1)
msg:Destroy()
elseif keyvals["resetteams"] then
msg.Text = "Resetting teams..."
a = game.Players:GetChildren()
for i,v in pairs(a) do
if v.TeamColor == BrickColor.new("Really blue") or BrickColor.new("Lime green") then
if v:GetRankInGroup(groupid) >= 9 then
v.TeamColor = BrickColor.new("Really red")
elseif v:GetRankInGroup(groupid) < 9 then
v.TeamColor = BrickColor.new("New Yeller")
end
end
end
wait(1)
msg:Destroy()
end
end
end
COMMUNITY QUESTION
Here is the problem?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please include what is wrong with your code, and try to add the Output error if there was any. We can not simply figure out the problem if we do not know what you are experiencing, and why the code isn't working, just simply posting code does not help us to figure out whats wrong with your script.