I have code that will run if you click a red button and then it closes some GUIs. When I click the button to disable it, it works and makes them disabled but when I try to enable them again, it does nothing. Any way to fix this? Sorry if this is easy to fix, I'm not that good at scripting and I didn't quite latch on to it.
Anyway, here is the code:
local playergui = game.Players.LocalPlayer.PlayerGui
local XButton = script.Parent
local PositionGui = playergui.PositionGui
local PositionGui2 = playergui.PositionGui2
local SpeedGui1 = playergui.SpeedGui1
local SpeedGui2 = playergui.SpeedGui2
local SpeedGui3 = playergui.SpeedGui3
local SpeedVelocityGui1 = playergui.SpeedVelocityGui1
local SpeedVelocityGui2 = playergui.SpeedVelocityGui2
local enabled = true
XButton.Activated:Connect(function(clicked)
if clicked and PositionGui.Enabled and PositionGui2.Enabled and SpeedGui1.Enabled and SpeedGui2.Enabled and SpeedGui3.Enabled and SpeedVelocityGui1.Enabled and SpeedVelocityGui2.Enabled and enabled == true then
PositionGui.Enabled = false
PositionGui2.Enabled = false
SpeedGui1.Enabled = false
SpeedGui2.Enabled = false
SpeedGui3.Enabled = false
SpeedVelocityGui1.Enabled = false
SpeedVelocityGui2.Enabled = false
enabled = false
script.Parent.BackgroundColor3 = Color3.fromRGB(17, 255, 0)
print("You clicked the button to deactivate the guis")
end
XButton.Activated:Connect(function(clicked2)
if clicked2 and PositionGui.Enabled == false and PositionGui2.Enabled == false and SpeedGui1.Enabled == false and SpeedGui2.Enabled == false and SpeedGui3.Enabled == false and SpeedVelocityGui1.Enabled == false and SpeedVelocityGui2.Enabled == false and enabled == false then
print("Passed second if")
PositionGui.Enabled = true
PositionGui2.Enabled = true
SpeedGui1.Enabled = true
SpeedGui2.Enabled = true
SpeedGui3.Enabled = true
SpeedVelocityGui1.Enabled = true
SpeedVelocityGui2.Enabled = true
enabled = true
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 4)
print("ran code")
end
end)
end)

1 comment
Try the new changes