So when you first start the game there would be a welcome screen GUI. I want to make a close button that destroys the GUI so it doesn't appear again after respawning because that is the current problem I have in my game. I made a local script in the text button and had this code that I made in there. It doesn't work and it just stops the game for 30 seconds.
function destroyGUI() game.StarterGui.ScreenGui.Frame.TextButton = destroyGUI() end script.Parent.MouseButton1Click:Connect(destroyGUI)
I don't think destroyGUI() is a thing.. change your line 3 into this
game.StarterGui.ScreenGui.Frame.TextButton:Destroy()
Try this:
script.Parent.MouseButton1Click:Connect(function(plr) -- plr is the player that clicked the button local Gui = plr.PlayerGui:FindFirstChild("ScreenGui") if Gui ~= nil then -- Checks if the player owns the gui Gui:Destroy() end end)