I made a button and script for hiding a particular screen gui but my script isnt working.
If anyone knows how to fix it please put the script on the comments.
the script
local Frame = script.Parent.Parent.Parent.Parent.VibeUi
local Button = script.Parent
local Text = Button.TextLabel
script.Parent.MouseButton1Click:Connect(function()
-- Playing the sound for each click
script.Parent.Parent.Parent.Sound:Play()
-- When clicked it will animate it in, when its clicked again it will animate out.
if Frame then
Button.ImageColor3 = Color3.fromRGB(0, 0, 0)
Text.Text = "HIDE UI"
else
Frame.Enabled = true
Button.ImageColor3 = Color3.fromRGB(255, 255, 255)
Text.Text = "SHOW UI"
end
end)
I think you should check if the ScreenGui is enabled or not.
local Frame = script.Parent.Parent.Parent.Parent.VibeUi
local Button = script.Parent
local Text = Button.TextLabel
script.Parent.MouseButton1Click:Connect(function()
-- Playing the sound for each click
script.Parent.Parent.Parent.Sound:Play()
-- When clicked it will animate it in, when its clicked again it will animate out.
if not Frame.Enabled then
Frame.Enabled = true
Button.ImageColor3 = Color3.fromRGB(0, 0, 0)
Text.Text = "HIDE UI"
else
Frame.Enabled = false
Button.ImageColor3 = Color3.fromRGB(255, 255, 255)
Text.Text = "SHOW UI"
end
end)