Edit: I forgot to put the parent of one of the messages as workspace so it only displayed the last message once it got taken out of lighting. Sorry mates my bad.

I made this capture the flag type game and put a script that ends the game by checking if all flags are owned by a team, then resetting it if they hold the flags for 35 seconds. The script works fine the first or second time, but sometimes if all flags are taken, it won't display a message or put the flags back to neutral, and also gives no errors. It also sometimes happens if one team takes over all the flags, but then the other team tries to take them back. I can't seem to find why this would be happening and was wondering what was wrong with it. Here's the script:

while true do
	wait(2)
	 if workspace.CFlag1.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag2.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag3.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag4.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag5.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag6.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlagPort.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     then
	M = Instance.new("Message") 
	 M.Parent = workspace
	 M.Text = "The Confederates Have Taken All The Flags! If They Hold Them For 35 Seconds, They Win."
	 wait(6)
	 M.Parent = game.Lighting
	 wait(29)
	 if
     workspace.CFlag1.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag2.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag3.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag4.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag5.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlag6.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     and workspace.CFlagPort.flagcapture.Flag.BrickColor == BrickColor.new("Bright red")
     then
	 M.Parent = workspace
	 M.Text = "The Confederates Have Destroyed The Yankee Forces! The River is Theirs!"
	 wait(8)
	 M:Destroy()
	workspace.CFlag1.flagcapture.Flag.BrickColor = BrickColor.new("White")
	 workspace.CFlag1.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag1.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag1.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlag2.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlag2.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag2.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag2.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlag3.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlag3.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag3.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag3.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlag4.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlag4.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag4.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag4.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlag5.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlag5.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag5.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag5.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlag6.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlag6.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlag6.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlag6.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	 workspace.CFlagPort.flagcapture.Flag.BrickColor = BrickColor.new("White")
	workspace.CFlagPort.flagcapture.Pole.Handles.Color3 = Color3.new(242, 243, 243)
	workspace.CFlagPort.flagcapture.ContestedSpawn.TeamColor = BrickColor.new("White")
	workspace.CFlagPort.flagcapture.ContestedSpawn1.TeamColor = BrickColor.new("White")
	else M:Destroy()
   end
  else 
 end
end
 

 

Everything seemed to be working fine until recently, but I haven't changed the script at all besides higher wait times.

8 comments

0

of course if u did change a think u would realise it cus its a mess

0

Is there any errors in the output?

0

No, I don't see any, it just isn't changing the flags or anything.

0

this gave me a headache

0

my eyes

0

yes I know it is ugly ree

0

use a for loop, this code is so unorganized it hurts

0

use variables to