Sorry, I assumed you only wanted the menu to appear once and not after the player dies as well.
If you want the menu to appear on screen after the player respawns, you could try replacing ResetOnSpawn with simply checking when the button is pressed.
local Menu = player.PlayerGui:WaitForChild("Menu", 5)
if Menu ~= nil then -- Make sure the UI exists
--Disable the character scripts
for i, v in character:GetDescendants() do
if not v:IsA("Script") or not v:IsA("LocalScript") then continue end
v.Enabled = false
end
--Check for whenever the play button is pressed
local PlayerLeaveConnect
local ButtonConnect
ButtonConnect = Menu.Path.To.Button.MouseButton1Down:Connect(function()
--Finally, enable the character scripts when the player presses the play button.
for i, v in character:GetDescendants() do
if not v:IsA("Script") or not v:IsA("LocalScript") then continue end
v.Enabled = true
end
--Prevent memory leaks
ButtonConnect:Disconnect()
ButtonConnect = nil
if PlayerLeaveConnect ~= nil then
PlayerLeaveConnect:Disconnect()
PlayerLeaveConnect = nil
end
end)
PlayerLeaveConnect = player.Destroying:Connect(function()
--Prevent memory leaks
if ButtonConnect ~= nil then
ButtonConnect:Disconnect()
ButtonConnect = nil
end
PlayerLeaveConnect:Disconnect()
PlayerLeaveConnect = nil
end)
else
--warn("Missing UI!")
end
Remember to change “Menu.Path.To.Button” to be correctly where your button is in the menu
And then remove the script connecting the play button to turning the UI’s ResetOnSpawn off. This way, the UI will still show because ResetOnSpawn is true, but we’ll be able to tell if the play button was pressed.
Would’ve posted this kind of solution a while ago but I was tired when writing my original solution.
This should work.