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

Why is domination the only working game mode out of 3?

Asked by 10 years ago

Alright, What the script is supposed to do is -Choose a game mode (3 game modes, domination,freeforall, and team deathmatch) -Choose a random map -Make the teams then start then start it But for some reason domination is the only one working, The others are stuck on making teams part.. Here is the script and thanks for taking you time to help!

_G.bluepoints = 0
_G.redpoints = 0
_G.toppoints = 0
_G.lead = 0
_G.top2points = 0

_G.message = function(msg)
for i,v in pairs(game.Players:GetChildren()) do
if v:findFirstChild("PlayerGui") then
if v.PlayerGui:findFirstChild("ScreenGui") then
v.PlayerGui.ScreenGui.GameMessage.Visible = true
v.PlayerGui.ScreenGui.GameMessage.MessageText.Text = msg
end
end
end
end

local towin = 0

function cleanup()
_G.toppoints = 0
_G.top2points = 0
_G.lead = 0

for i,v in pairs(workspace:GetChildren()) do
if v:findFirstChild("Base") then
if v.Base:findFirstChild("RealTransparency") then
v:Destroy()
end
end
if v:findFirstChild("Humanoid") then
v.Humanoid.Health = 0
end
end


game.Teams:ClearAllChildren()
new = Instance.new("Team", game.Teams)
new.Name = "Waiting"
new.TeamColor = BrickColor.new("Mid gray")
new.AutoAssignable = true

for i,v in pairs(game.Players:GetChildren()) do
v.TeamColor = BrickColor.new("Mid gray")
end

for i,v in pairs(workspace.Leaderboard:GetChildren()) do
if string.find(v.Name, "kill") then
v.Value = 0
end
end

workspace.Map:Destroy()
end

wait(2)

while true do
wait(1)
for i,v in pairs(game.Players:GetChildren()) do
if v:findFirstChild("PlayerGui") then
if v.PlayerGui:findFirstChild("ScreenGui") then
v.PlayerGui.ScreenGui.TopKills.First.Text = "First: ".. _G.toppoints
v.PlayerGui.ScreenGui.TopKills.Second.Text = "Second: ".. _G.top2points
if script.Parent.Parent:findFirstChild(v.Name.."kills") then
v.PlayerGui.ScreenGui.TopKills.You.Text = "You: ".. script.Parent.Parent[v.Name.."kills"].Value .." Kills"
end
end
end
end
if script.Parent.Value == "Free For All" then
if _G.toppoints >= towin then
script.Parent.Value = ""
script.Parent.Parent[_G.lead.Name].Value = script.Parent.Parent[_G.lead.Name].Value+1500
_G.message(_G.lead.Name.. " has won the match and earned 1500 EXP!")
wait(3)
cleanup()
wait(3)

end
end
if script.Parent.Value == "Team Deathmatch" then
if _G.bluepoints >= towin or _G.redpoints >= towin then
script.Parent.Value = ""

if _G.bluepoints >= towin then
_G.message("Blue wins! Every blue team member gets 1000 EXP!")
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Bright blue") then
if v:findFirstChild("leaderstats") then
script.Parent.Parent[v.Name].Value = script.Parent.Parent[v.Name].Value+1000
end
end
end
end

if _G.redpoints >= towin then
_G.message("Red wins! Every red team member gets 1000 EXP!")
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Bright red") then
if v:findFirstChild("leaderstats") then
script.Parent.Parent[v.Name].Value = script.Parent.Parent[v.Name].Value+1000
end
end
end
end

wait(3)
cleanup()
wait(3)
end
end

if script.Parent.Value == "Domination" then
if _G.bluepoints >= towin or _G.redpoints >= towin then
script.Parent.Value = ""

if _G.bluepoints >= towin then
_G.message("Blue wins! Every blue team member gets 1000 EXP!")
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Bright blue") then
if v:findFirstChild("leaderstats") then
script.Parent.Parent[v.Name].Value = script.Parent.Parent[v.Name].Value+1000
end
end
end
end

if _G.redpoints >= towin then
_G.message("Red wins! Every red team member gets 1000 EXP!")
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Bright red") then
if v:findFirstChild("leaderstats") then
script.Parent.Parent[v.Name].Value = script.Parent.Parent[v.Name].Value+1000
end
end
end
end

cleanup()
wait(3)
end
end

if script.Parent.Value == "" then

_G.message("Starting a new game!")

wait(3)
_G.message("Picking map and gamemode..")
wait(3)

local maps = {} for i,v in pairs(game.Lighting.Maps:GetChildren()) do table.insert(maps, v) end
local modes = {"Team Deathmatch", "Domination", "Free For All"}

map = game:GetService("InsertService"):LoadAsset(maps[math.random(#maps)].Value)
mode = modes[math.random(#modes)]

for i,v in pairs(map:GetChildren()) do
v.Parent = workspace
map = v
end


_G.message(mode.." on "..map.Name.. " chosen!")

wait(3)

if mode == "Domination" then
wait(3)
_G.message("Making teams..")
game.Teams.Waiting:Destroy()

red = Instance.new("Team", game.Teams)
red.Name = "Red"
red.TeamColor = BrickColor.new("Bright red")
red.AutoAssignable = true

blue = Instance.new("Team", game.Teams)
blue.Name = "Blue"
blue.TeamColor = BrickColor.new("Bright blue")
blue.AutoAssignable = true

for i,v in pairs(game.Players:GetChildren()) do
wait(0.1)
if i/2 == math.floor(i/2) then
v.TeamColor = BrickColor.new("Bright red")
else
v.TeamColor = BrickColor.new("Bright blue")
end
end
_G.message("In the Domination gamemode, you must control selected flags on the map for points and spawns!")
towin = 200
end

if mode == "Free For All" then

for i,v in pairs(game.Players:GetChildren()) do
local team = script.Parent.Parent.TeamMaker:clone()
team.Player.Value = v.Name
team.Parent = workspace
team.Disabled = false
end

_G.message("In Free For All gamemode, it's you against everyone!")
for i,v in pairs(map.Flags:GetChildren()) do
v.CFrame = v.CFrame-Vector3.new(0,200,0)
end
map.Flags.Flag1.BrickColor = BrickColor.new("White")
map.Flags.Flag3.BrickColor = BrickColor.new("White")
for i,v in pairs(map:GetChildren()) do
if v.Name == "ColorPart1" then
v.BrickColor = BrickColor.new("White")
end
if v.Name == "ColorPart3" then
v.BrickColor = BrickColor.new("White")
end
if v.Name == "FlagPoles" then
v:Destroy()
end
end
towin = 15
end

if mode == "Team Deathmatch" then
_G.message("In Team Deathmatch gamemode, you must kill enemy players until the score limit is reached!")

wait(3)
_G.message("Making teams..")
game.Teams.Waiting:Destroy()

red = Instance.new("Team", game.Teams)
red.Name = "Red"
red.TeamColor = BrickColor.new("Bright red")
red.AutoAssignable = true

blue = Instance.new("Team", game.Teams)
blue.Name = "Blue"
blue.TeamColor = BrickColor.new("Bright blue")
blue.AutoAssignable = true

for i,v in pairs(game.Players:GetChildren()) do
wait(0.1)
if i/2 == math.floor(i/2) then
v.TeamColor = BrickColor.new("Bright red")
else
v.TeamColor = BrickColor.new("Bright blue")
end
end

for i,v in pairs(map.Flags:GetChildren()) do
v.CFrame = v.CFrame-Vector3.new(0,200,0)
end
map.Flags.Flag1.BrickColor = BrickColor.new("Bright red")
map.Flags.Flag3.BrickColor = BrickColor.new("Bright blue")
for i,v in pairs(map:GetChildren()) do
if v.Name == "ColorPart1" then
v.BrickColor = BrickColor.new("Bright red")
end
if v.Name == "ColorPart3" then
v.BrickColor = BrickColor.new("Bright blue")
end
if v.Name == "FlagPoles" then
v:Destroy()
end
end
towin = 50
end

wait(5)
for i,v in pairs(game.Players:GetChildren()) do
if v:findFirstChild("PlayerGui") then
if v.PlayerGui:findFirstChild("ScreenGui") then
v.PlayerGui.ScreenGui.GameMessage.Visible = false
end
end
end

map.Name = "Map"
script.Parent.Value = mode
end
end

0
Posting a 282 line script expecting answers is not going to work. Please post the section that you are having issues with. Articulating 1335 — 10y

Answer this question