In the script below it always chooses the last if statement. The values are intvalues that count up the points. And if a team wins it will show the points comparing but if the teams tie it will show it was a tie. But for some reason it always says its a tie even tho a value is greater than the other. Can anyone help? Sorry if you didn't understand.
local GameLength = workspace.MapChosen:FindFirstChildWhichIsA("Folder").Info.GameLength.Value for i = GameLength,1,-1 do Status.Value = "Destroy the other teams statue before the other team does!".." (" ..i..")" for x, player in pairs(plrs) do if player then local character = player.Character if not character then table.remove(plrs,x) end wait(1) end if i == 1 then local BlueTeamStatue = script.Parent.RedTeamStatue:FindFirstChild("Tracker") local RedTeamStatue = script.Parent.RedTeamStatue:FindFirstChild("Tracker") if RedTeamStatue.Value.Value < BlueTeamStatue.Value.Value then Status.Value = "Red team wins! with a score of ".. tostring(RedTeamStatue.Value.Value).. " to " .. tostring(BlueTeamStatue.Value.Value) ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) break elseif BlueTeamStatue.Value.Value < RedTeamStatue.Value.Value then Status.Value = "Blue team wins! with a score of ".. tostring(BlueTeamStatue.Value.Value).. " to " .. tostring(RedTeamStatue.Value.Value) ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) break elseif BlueTeamStatue.Value.Value == RedTeamStatue.Value.Value then Status.Value = "It was a tie!" ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) end end end end
You have a minor typo which is causing you to compare the red team's score with itself. Additionally, you have a bug in the logic, which is obscured by improper indentation. Let's format your code correctly:
local GameLength = workspace.MapChosen:FindFirstChildWhichIsA("Folder").Info.GameLength.Value for i = GameLength, 1, -1 do Status.Value = "Destroy the other teams statue before the other team does!" .. " (" .. i .. ")" for x, player in pairs(plrs) do if player then local character = player.Character if not character then table.remove(plrs, x) end wait(1) end -- !!! The following code runs several times when i reaches 1, once for each player. -- You probably want to move this outside the for loop. if i == 1 then local BlueTeamStatue = script.Parent.BlueTeamStatue:FindFirstChild("Tracker") -- Here, I changed script.Parent.RedTeamStatue to script.Parent.BlueTeamState local RedTeamStatue = script.Parent.RedTeamStatue:FindFirstChild("Tracker") if RedTeamStatue.Value.Value < BlueTeamStatue.Value.Value then Status.Value = "Red team wins! with a score of " .. tostring(RedTeamStatue.Value.Value) .. " to " .. tostring(BlueTeamStatue.Value.Value) ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) break elseif BlueTeamStatue.Value.Value < RedTeamStatue.Value.Value then Status.Value = "Blue team wins! with a score of " .. tostring(BlueTeamStatue.Value.Value) .. " to " .. tostring(RedTeamStatue.Value.Value) ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) break elseif BlueTeamStatue.Value.Value == RedTeamStatue.Value.Value then Status.Value = "It was a tie!" ValueRemover() game.Teams.Red:Destroy() game.Teams.Blue:Destroy() wait(5) end end end end