How do I make a menu that appears every time a player dies, so he can choose to spectate or to join the next round? Kind of like in piggy.
You can use Humanoid.Died
for this one since you want the ui to display when player dies
How do I make a script for this ? (I’m kind of a beginner)
You could hook up a Humanoid.Died connection, set it so it shows the death screen, with buttons that do an event. I recommend you set ResetOnSpawn to true as the death screen should only spawn when the player dies.
Set CharacterAutoLoads to false, and in the main menu, call Player:LoadCharacter(). If you want a respawn button, hook it to a RemoteEvent in which the server receives the request and uses the default player passed parameter to call Player:LoadCharacter(). Note: Make sure the respawn button only sends signal once, or you could get some pretty wacky physics.
In my game, which isn’t fully released yet, I used TweenService to animate death screen slowly showing. I also used the above methods.
LocalScript in StarterCharacterScripts:
local c:Model = script.Parent
local h:Humanoid = c:WaitForChild("Humanoid")
local p = game:GetService("Players").LocalPlayer
local playergui = p:WaitForChild("PlayerGui")
h.Died:Connect(function()
playergui["Gui"].Enabled = true -- sets a *screengui* instance to enabled
end)