-- GUI Elements

local gui = script.Parent
local textDisplay = gui.Header
local displayImage = gui.DisplayImage

local scriptAttributes = script:GetAttributes()

local function displayEndScreen(state, transitionTime)
	-- Make the GUI visible
	
	gui.Visible = true
	
	if state == "Victory" then
		textDisplay.Text = gui:GetAttribute("messageVictory")
		displayImage.Image = gui:GetAttribute("imageVictory")
	elseif state == "Defeat" then
		textDisplay.Text = gui:GetAttribute("messageDefeat")
		displayImage.Image = gui:GetAttribute("imageDefeat")
	else
		warn("Invalid end game state fired on client GUI")
	end
	
	wait(transitionTime)
	gui.Visible = false
	
end

ClientEndGame.OnClientEvent:Connect(displayEndScreen)

