How to make it, so button closes the GUI?

Try mines. I fixed it. Maybe it will work

local player = game:GetService(“Players”).LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
wait(0.50)
script.Parent.Parent.Parent.ScreenGui.Visible = true
script.Parent.Text = “Close Warning GUI”
else
player.PlayerGui.ScreenGui.Frame.Visible = true
wait(0.5)
script.Parent.Parent.Parent.ScreenGui.Visible = false
script.Parent.Text = “Open Warning GUI”
end
end)

Your code doesn’t work, also when formatting the script, please use the format of:

" ``` " on the top of the script, and at the buttom of the script, thanks! (ignore the " ")

Example: print("hi")

Did anyone refer my script because i have tested it and its working

local player = game.Players.LocalPlayer
local state = false -- the gui is closed if its false

script.Parent.MouseButton1Click:Connect(function()
	if not state then
		wait(0.50)
		player.PlayerGui.ScreenGui.Frame.Visible = true
		script.Parent.Text = "Close Warning GUI"
		state = true
	else
		player.PlayerGui.ScreenGui.Frame.Visible = false
		script.Parent.Text = "Open Warning GUI"
		state = false
	end
end)
1 Like

Your script does work, thanks.

Please refrain from making further conversations below. V V V

WarnGui.rbxl (28.8 KB)