I’ve basically figured out the great majority of my script, it all works just fine. I can’t seem to figure out how to go about disabling the gui again. I know that I would just set it to enabled = false. However, I am not sure where in my script I would go about doing that, or if the logic allows it?
local playersService = game:GetService("Players")
local teams = game:GetService("Teams")
local teamBloods = teams.Bloods:GetPlayers()
local pole1 = game.Workspace.Point1.pole1
local pole2 = game.Workspace.Point2.pole2
local pole3 = game.Workspace.Point3.pole3
while true do
local playerPoints = 0
local players = playersService:GetPlayers()
local teamCrips = teams.Crips:GetPlayers()
local teamBloods = teams.Bloods:GetPlayers()
for i, v in pairs(teamCrips)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Crips have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
for i, v in pairs(teamBloods)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Bloods have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
wait(1)
end
I am a bit stumped because I don’t think that I could put Enabled = false within a for i, v in pairs loop because then the wait() wouldn’t work?
From my understanding of the code I think they would go here
local playersService = game:GetService("Players")
local teams = game:GetService("Teams")
local pole1 = game.Workspace.Point1.pole1
local pole2 = game.Workspace.Point2.pole2
local pole3 = game.Workspace.Point3.pole3
while true do
local playerPoints = 0
local players = playersService:GetPlayers()
local teamCrips = teams.Crips:GetPlayers()
local teamBloods = teams.Bloods:GetPlayers()
for i, v in pairs(teamCrips)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Crips have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
-- disable gui here
end
end
for i, v in pairs(teamBloods)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Bloods have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
-- disable gui here
end
end
wait(1)
end
I did this and it still does not work, though it looked like the logic was right, odd. Maybe it’s because it is firing before the GUI has been enabled, but I’m again not sure how to add a wait to that and it work. I tried adding a wait and it didn’t help anything.
local playersService = game:GetService("Players")
local teams = game:GetService("Teams")
local teamBloods = teams.Bloods:GetPlayers()
local pole1 = game.Workspace.Point1.pole1
local pole2 = game.Workspace.Point2.pole2
local pole3 = game.Workspace.Point3.pole3
while true do
local playerPoints = 0
local players = playersService:GetPlayers()
local teamCrips = teams.Crips:GetPlayers()
local teamBloods = teams.Bloods:GetPlayers()
for i, v in pairs(teamCrips)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Crips have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
v.PlayerGui.ScreenGui2.Enabled = false
end
end
for i, v in pairs(teamBloods)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Bloods have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
v.PlayerGui.ScreenGui2.Enabled = false
end
end
wait(1)
end
local playersService = game:GetService("Players")
local teams = game:GetService("Teams")
local teamBloods = teams.Bloods:GetPlayers()
local pole1 = game.Workspace.Point1.pole1
local pole2 = game.Workspace.Point2.pole2
local pole3 = game.Workspace.Point3.pole3
while true do
local playerPoints = 0
local players = playersService:GetPlayers()
local teamCrips = teams.Crips:GetPlayers()
local teamBloods = teams.Bloods:GetPlayers()
for i, v in pairs(teamCrips)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Crips have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
for i, v in pairs(teamBloods)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Bloods have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
wait(3) -- wait for some seconds
v.PlayerGui.ScreenGui2.Enabled = false
end
Well the issue with that is that v has a nil value. That’s within the while loop but not within the for i, v in pairs() loops. Unless you’ve added in something else that I missed.
local playersService = game:GetService("Players")
local teams = game:GetService("Teams")
local teamBloods = teams.Bloods:GetPlayers()
local pole1 = game.Workspace.Point1.pole1
local pole2 = game.Workspace.Point2.pole2
local pole3 = game.Workspace.Point3.pole3
while true do
local playerPoints = 0
local players = playersService:GetPlayers()
local teamCrips = teams.Crips:GetPlayers()
local teamBloods = teams.Bloods:GetPlayers()
for i, v in pairs(teamCrips)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Crips have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
for i, v in pairs(teamBloods)do
playerPoints = playerPoints + v.leaderstats.Points.Value
if playerPoints >= 1000 then
for i, v in pairs(players)do
v.PlayerGui.ScreenGui2.TextLabel.Text = ("Bloods have won")
v.PlayerGui.ScreenGui2.Enabled = true
v.leaderstats.Points.Value = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsCrips.Text = 0
v.PlayerGui.ScreenGui.PointsDisplay.PointsBloods.Text = 0
pole1.BrickColor = BrickColor.new("Medium stone grey")
pole2.BrickColor = BrickColor.new("Medium stone grey")
pole3.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
wait(3)
for i, v in pairs(players) do
v.PlayerGui.ScreenGui2.Enabled = false
end