Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local scriptGui = nil
- -- Function to create the script GUI
- local function createScriptGui()
- if not scriptGui then
- -- [Your existing code to create the GUI here]
- -- Example usage
- -- local title = "Important Message"
- -- local message = "Hello, this is an important message for you!"
- -- createMessageDialog(title, message)
- end
- end
- -- Function to destroy the script GUI
- local function destroyScriptGui()
- if scriptGui then
- scriptGui:Destroy()
- scriptGui = nil
- end
- end
- -- Recreate the GUI when the player respawns
- player.CharacterAdded:Connect(function(character)
- createScriptGui()
- end)
- -- Destroy the GUI when the player leaves the game
- player:Connect(function()
- destroyScriptGui()
- end)
- -- Call the createScriptGui function once when the script starts
- createScriptGui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement