I have a system that when you die, the game shows you your score. The score Gui gets cloned but only appears for 1 second. Is there a way for the game to wait for the Player to click on the Button, and then the score Gui disappears?
function showResults(player)
local resultsGUI = game.ServerStorage.GUIs.PostRunGUI:Clone()
resultsGUI.Frame.DistanceValue.Text = player.RunStats.Distance.Value
resultsGUI.Frame.CoinsValue.Text = player.RunStats.CoinsCollected.Value
resultsGUI.Frame.ScoreValue.Text = player.leaderstats.Score.Value
resultsGUI.Parent = player.PlayerGui
resultsGUI.Frame.MainMenuBtn.MouseButton1Click:Connect(function()
resultsGUI:Destroy() -- This is what happens when the player clicks on the Button
end)
end
function showResults(player)
local resultsGUI = game.ServerStorage.GUIs.PostRunGUI:Clone()
resultsGUI.Frame.DistanceValue.Text = player.RunStats.Distance.Value
resultsGUI.Frame.CoinsValue.Text = player.RunStats.CoinsCollected.Value
resultsGUI.Frame.ScoreValue.Text = player.leaderstats.Score.Value
resultsGUI.Parent = player.PlayerGui
resultsGUI.Frame.MainMenuBtn.MouseButton1Click:Connect(function()
resultsGUI:Destroy()
end)
end
function initialiseNewRun(player, delayTime, charExpected, showLastResults)
if not path then
while not path do
wait()
end
end
local lastResultsGUI = nil
if showLastResults then
lastResultsGUI = showResults(player)
end
if lastResultsGUI ~= nil then
lastResultsGUI:Destroy()
end
if player and player.Parent then
-- charExpected is needed to avoid calling LoadCharacter on players leaving the game
if player.Character or charExpected == false then
player:LoadCharacter()
initialiseRunStats(player)
local playersPath = path()
lastActivePath[player.Name] = playersPath
playersPath:init(player.Name)
end
end
end