i made a settings gui for the player to cut off the music or turn it on and the only problem is that the gui is by default showing
i tried moving the code or setting true to false... but nothing worked, i will addd the code below
local open = true
script.Parent.MouseButton1Click:Connect(function()
if open == true then
open = false
script.Parent.Parent.Parent.MainFrame:TweenPosition(UDim2.new(0.278, 0,0.319, 0), "InOut", "Quad", 0.5, true)
else
open = true
script.Parent.Parent.Parent.MainFrame:TweenPosition(UDim2.new(0.278, 0,1, 0), "InOut", "Quad", 0.5, true)
end
end)
How are you showing the GUI to the player?
This also means subsequent frames that have their .Visibile property turned on, will also automatically be shown.
All in all, it means that the GUI is set to show itself first thing it's parented.
To solve this you might want your localscript to also control the appropiate properties of the ScreenGui and frames you want to show.
E.g.
local mainFrame = script.Parent.Parent.Parent.MainFrame
local open = true
script.Parent.MouseButton1Click:Connect(function()
if open == true then
open = false
mainFrame:TweenPosition(UDim2.new(0.278, 0,0.319, 0), "InOut", "Quad", 0.5, true)
task.wait(0.5)
mainFrame.Visible = false
else
open = true
mainFrame.Visible = true
mainFrame:TweenPosition(UDim2.new(0.278, 0,1, 0), "InOut", "Quad", 0.5, true)
end
end)
Of course, there also might be the start position of the frame isn't properly set causing the issue you currently have. You'd have to either set it in the GUI editing mode, or at the start of a localscript:
...
mainFrame.Position = UDim2.new(0.278, 0,0.319, 0)
...
-- the rest of the code
...