Servers Operational
Live Triage→
RobloxDownloads Official LogoRobloxDownloads.com

Independent Technical Resource & Anti-Phishing ShieldVerified Safe

RobloxDownloads.com is an independent diagnostic database. We do NOT host executable binaries (.exe, .dmg, .apk). All download action links redirect directly to verified first-party official sources (Roblox Corporation, Microsoft Store, Apple App Store, Google Play).

Roblox Studio & Luau EngineSeverity: RUNTIME_NIL_EXCEPTIONReplication & Hierarchy

PlayerGui resets on respawn & UI disappears: ResetOnSpawn & ScreenGui Lifecycle

When a player dies and respawns, Roblox by default wipes all ScreenGuis in PlayerGui and clones fresh copies from StarterGui. This destroys active UI script variables and breaks event connections. Fix this by disabling ResetOnSpawn on persistent ScreenGuis.

Verified Engine: Studio 0.650+ / Luau 2026 Engine
•
Subsystems: PlayerGui Service, ScreenGui Lifecycle, StarterGui

PLAYERGUI_RESET_ON_SPAWN_BUG is a Luau VM and Roblox Studio diagnostic event triggered by "attempt to index nil with 'PlayerGui' (or UI disappears upon player death)". When a player dies and respawns, Roblox by default wipes all ScreenGuis in PlayerGui and clones fresh copies from StarterGui. This destroys active UI script variables and breaks event connections. Fix this by disabling ResetOnSpawn on persistent ScreenGuis.

Roblox Studio Error Specifications & Technical Architecture
Telemetry MetricVerified Value
Error Signatureattempt to index nil with 'PlayerGui' (or UI disappears upon player death)
Fault ClassificationRUNTIME_NIL_EXCEPTION (Replication & Hierarchy)
Affected SubsystemsPlayerGui Service, ScreenGui Lifecycle, StarterGui
Engine VerificationStudio 0.650+ / Luau 2026 Engine
Quick RemediationUnchecking ResetOnSpawn ensures the ScreenGui and all child elements persist across character deaths without being destroyed.
Roblox Studio — Output Window Console
Live Engine Diagnostics
attempt to index nil with 'PlayerGui' (or UI disappears upon player death)

This exact red trace is logged when the Luau VM or engine runtime encounters a thread halt, unhandled nil reference, or cloud quota block.

🔬

Deep-Dive Architectural Root Cause

Every ScreenGui in StarterGui has a property named ResetOnSpawn which defaults to true. When a character dies, the Roblox core GUI manager deletes the player's existing GUI hierarchy and creates brand-new instances. If local scripts stored references to UI buttons outside the character lifecycle, those references become invalid pointers to destroyed instances.

💻 Code Implementation Comparison

Inspect the flawed snippet causing the runtime fault vs. the hardened, production-grade Luau solution.

❌ Vulnerable / Buggy SnippetAnti-Pattern
Command / Path
-- ❌ BROKEN: ScreenGui has ResetOnSpawn = true, but script is in StarterPlayerScripts
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local shopButton = playerGui:WaitForChild("ShopGui"):WaitForChild("OpenButton")

-- On first death, ShopGui is destroyed and recreated, but shopButton still points to the DEAD button!
shopButton.Activated:Connect(function()
    print("This will stop working after player respawns!")
end)

Halts thread execution, creates memory leaks, or trips engine watchdogs when unexpected nil states occur.

✅ Hardened Production FixLuau 2026 Engine Ready
Command / Path
-- ✅ PRODUCTION FIX: Persistent UI Architecture
-- 1. In Roblox Studio Properties Window:
-- Select your ScreenGui inside StarterGui -> Uncheck "ResetOnSpawn"

-- 2. In LocalScript (placed inside StarterPlayerScripts or ReplicatedFirst):
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = playerGui:WaitForChild("PersistentShopGui") :: ScreenGui
local openButton = screenGui:WaitForChild("OpenButton") :: TextButton

openButton.Activated:Connect(function()
    print("✅ This connection survives unlimited respawns because ResetOnSpawn is false!")
end)

Zero unhandled yields, guarded type narrowing, safe fallback paths, and production reliability.

🛠️ Engineering Resolution Steps

  1. 1Unchecking ResetOnSpawn ensures the ScreenGui and all child elements persist across character deaths without being destroyed.
  2. 2Placing UI control scripts in StarterPlayerScripts prevents scripts from re-running and creating duplicate event listeners upon each death.
  3. 3Conserves client memory and eliminates interface flicker during the respawn sequence.

⚙️ Roblox Studio Configuration Checklist

✔Select ScreenGui in Explorer > Properties > Uncheck ResetOnSpawn.
✔Place master UI management scripts in StarterPlayerScripts rather than inside the ScreenGui itself if you want continuous state.

❓ Frequently Asked Developer Questions

When SHOULD ResetOnSpawn remain checked (true)?

Keep ResetOnSpawn enabled only for temporary gameplay overlays, such as a health bar or killcam that specifically needs a fresh reset for the new character.

Related Roblox Studio & Luau Diagnostics

Explore other compiler warnings, runtime exceptions, and developer telemetry tools.

Browse Full Studio Matrix →