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

Why is this GUI managing script not working correctly?

Asked by 8 years ago

The script is supposed to detect if the player's team is winning, losing, or tying the game.

However, the only thing the script does is make the GUI say that the game was a "Tie," even if the player won/lost the game.

I have no idea why this is happening, as output gave me nothing on this issue.

Can someone please help me? Here's the script:

local Detect = game.ServerScriptService.MainGame:WaitForChild("Score1")
local Detect2 = game.ServerScriptService.MainGame:WaitForChild("Score2")
local Defeat = script.Parent:WaitForChild("Defeat")
local Victory = script.Parent:WaitForChild("Victory")
local Tie = script.Parent:WaitForChild("Tie")

while wait(0.1) do
    if Detect.Value > Detect2.Value then
        if script.Parent.Parent.Parent.Parent.Parent.TeamColor == BrickColor.new("Bright green") then
            Defeat.Visible = false
            Victory.Visible = true
            Tie.Visible = false
        elseif script.Parent.Parent.Parent.Parent.Parent.TeamColor == BrickColor.new("Bright red") then
            Defeat.Visible = true
            Victory.Visible = false
            Tie.Visible = false
        end
    elseif Detect.Value < Detect2.Value then
        if script.Parent.Parent.Parent.Parent.Parent.TeamColor == BrickColor.new("Bright green") then
            Defeat.Visible = false
            Victory.Visible = true
            Tie.Visible = false
        elseif script.Parent.Parent.Parent.Parent.Parent.TeamColor == BrickColor.new("Bright red") then
            Defeat.Visible = true
            Victory.Visible = false
            Tie.Visible = false
        end
    elseif Detect.Value == Detect2.Value then
        Defeat.Visible = false
        Victory.Visible = false
        Tie.Visible = true
    end
end 

Answer this question