Advertisement
13ooeo

no dissapear ui when die

Jul 23rd, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local playerGui = player:WaitForChild("PlayerGui")
  3. local scriptGui = nil
  4.  
  5. -- Function to create the script GUI
  6. local function createScriptGui()
  7. if not scriptGui then
  8. -- [Your existing code to create the GUI here]
  9.  
  10. -- Example usage
  11. -- local title = "Important Message"
  12. -- local message = "Hello, this is an important message for you!"
  13.  
  14. -- createMessageDialog(title, message)
  15. end
  16. end
  17.  
  18. -- Function to destroy the script GUI
  19. local function destroyScriptGui()
  20. if scriptGui then
  21. scriptGui:Destroy()
  22. scriptGui = nil
  23. end
  24. end
  25.  
  26. -- Recreate the GUI when the player respawns
  27. player.CharacterAdded:Connect(function(character)
  28. createScriptGui()
  29. end)
  30.  
  31. -- Destroy the GUI when the player leaves the game
  32. player:Connect(function()
  33. destroyScriptGui()
  34. end)
  35.  
  36. -- Call the createScriptGui function once when the script starts
  37. createScriptGui()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement