So, I'm making a spectate button, and I'm trying to make it so when you press the "exit" button, the spectate gui will close. However, this works, but only once for some reason. Help would be appreciated,
(These are both local scripts)
script 1 (inside the button that opens the gui)
local player = game.Players.LocalPlayer
local open = false
script.Parent.MouseButton1Click:Connect(function()
if open == false then
open = true
local Spectating = Instance.new("BoolValue")
Spectating.Name = "Spectating"
Spectating.Parent = player
script.Parent.Parent.Background.Visible = true
print("Visible")
end
end)
script 2 (Inside the gui)
script.Parent.Exit.MouseButton1Click:Connect(function()
if plr:FindFirstChild("Spectating") then
plr.Spectating:Destroy()
script.Parent.Visible = false
print("NotVisible")
end
end)

1 comment
Thank you very much, it works!