Enable UI after death?

How can I enable a UI after I kill the players once the round ends, and the intermission starts again?

Here is my UI:

Here is my script where I want to turn on the UI:

game.ReplicatedStorage.EndOfRound.OnServerEvent:Connect(function(player)
	for i, v in pairs(player.Backpack:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
	
	for i, v in pairs(player.StarterGear:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
	
	wait(10.25)
	player.Character:WaitForChild("Humanoid").Health = 0
	player.leaderstats:FindFirstChild("Points").Value += math.random(10,15)
end)

The script is in the ServerScriptService

Help Soon,

papahetfan

1 Like

Here is an example of the code

Player.Character:FindFirstChild("Humanoid").Died:Connect(function()

end)

After that fire a Remote event to make the gui appear on the client.

Would the UI be enabled still if the player Respawns?

Put this in a server script in the ServerScriptService.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:WaitForChild("Humanoid").Died:Connect(function()
			player.PlayerGui:FindFirstChild("GuiNameHere").Enabled = true -- put your gui name here
		end)
	end)
end)
game.ReplicatedStorage.EndOfRound.OnServerEvent:Connect(function(player)
	for i, v in pairs(player.Backpack:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
	
	for i, v in pairs(player.StarterGear:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
	
	wait(10.25)
	player.Character:WaitForChild("Humanoid").Health = 0
	local hum = player.Character:FindFirstChild("Humanoid")
	hum.Died:Connect(function()
		player.PlayerGui:FindFirstChild("PlayScreen").Enabled = true
	end)
	player.leaderstats:FindFirstChild("Points").Value += math.random(10,15)
end)

Tried it out and it did not work, any problems I can fix. I saw no errors in the output either.

Don’t put this in a remote event, I am not the guy who suggested a remote event, that was @lilmazen1234. Just put my script as a server script in the ServerScriptService.

Try this:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	local PlrGui = plr.PlayerGui
	plr.CharacterAdded:Connect(function(chr)
		chr:WaitForChild("Humanoid").Died:Connect(function()
			PlrGui:FindFirstChild("EndRoundGui").Enabled = true -- make sure this gui has ResetOnDeath to false! Otherwise the gui may disappear when the player respawns!
		end)
	end)
end)

Hope this helps!