I’m currently working on a music UI, but I’m having issues on scripting an open close system. I want the script to check if the playlist is opened, and if its opened, it closes the ui. But the problem is, when i open, it closes automatically. I’m pretty bad at scripting, so it can be a small issue as well which I couldn’t find.
Parents
Script (PlaylistOpenHandler)
--//Techyfied\\--
local playlistFrame = script.Parent.Playlist
local playlistButton = script.Parent.MainFrame.PlaylistOpen
local closeButton = script.Parent.Playlist.Close
local isOpened = false
closeButton.MouseButton1Click:Connect(function()
if isOpened == false then
print("Could not be closed because it's already closed. How did you even click this button lol")
end
if isOpened == true then
print("Playlist is opened. Closing..")
playlistFrame:TweenPosition(UDim2.new(-0.3, 0, 0.227, 0), 'Out', 'Back', 1)
isOpened = false
print("Successfully closed.")
wait(1)
end
end)
playlistButton.MouseButton1Click:Connect(function()
if isOpened == false then
print("Play list is closed. Opening..")
playlistFrame:TweenPosition(UDim2.new(0.023, 0, 0.227, 0), 'Out', 'Back', 1)
isOpened = true
print("Successfully opened.")
wait(1)
end
if isOpened == true then
print("Playlist is opened. Closing..")
playlistFrame:TweenPosition(UDim2.new(-0.3, 0, 0.227, 0), 'Out', 'Back', 1)
isOpened = false
print("Successfully closed.")
end
end)
Output after clicking on the PlaylistOpen button only
Here, UDim2.new(-0.3, 0, 0.227, 0)
is the Playlist frame’s closed position and UDim2.new(0.023, 0, 0.227, 0)
is the Playlist frame’s opened position. The frame appears, waits 1 second and it closed. And that’s my issue. Any help is appreciated!