Where and how do i implement this?

DESCRIPTION

So I’m making a plugin for UI Designers to have to make their designing life easier, and what I’m trying to do is make a Search Filter for the plugin to make finding the assets easier for the person using the said plugin.

MY PROBLEM

This script only runs correctly ONCE, and then it completely bugs out and stops working.

MY SCRIPT

local MainFrame = script.Parent.Parent.Parent.MainFrame
local drop = script.Parent
local menu = drop.Menu
local open = menu.Open.Value
local selection = drop.Selection
local Frame1 = script.Parent.Parent.ButtonsDropdown
local Frame2 = script.Parent.Parent.FramesDropdown
local Frame3 = script.Parent.Parent.LightingDropdown
local Frame4 = script.Parent.Parent.IconsDropdown
local Open1 = Frame1.Menu.Open
local Open2 = Frame2.Menu.Open
local Open3 = Frame3.Menu.Open
local Open4 = Frame4.Menu.Open

local function closeFrames()
	for _, item in ipairs(Frame2:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame3:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame4:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
end

function trigger()
	if not open then
		menu:TweenSize(UDim2.new(1, 0, 6.238, 0), "Out", "Sine", 0.15, true)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = true
			end
		end
		wait(0.001)
		open = true
	else
		closeFrames()
		wait(0.001)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = false
			end
		end
		open = false
		Open2 = false
		Open3 = false
		Open4 = false
	end
end

selection.MouseButton1Click:Connect(trigger)

for _, button in pairs(menu:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseEnter:Connect(function()
			button.BackgroundTransparency = 0.8
		end)
		button.MouseLeave:Connect(function()
			button.BackgroundTransparency = 1
		end)
		button.MouseButton1Click:Connect(function()
			script.Parent.Parent.Parent.CurrentPage.Text = button.Text.." Buttons"
			trigger()
		end)
	end
end

WHERE I THINK THE PROBLEM RESIDES

Even with my minimal scripting knowledge, I can still take a guess on where the problem comes from:

Here ↓

Even More Specifically Here ↓

Capture

Maybe it’s as a result of the open value not returning to true or something? I really don’t know.

VIDEO

EXPLORER PICTURE

Capture

Thank you to everyone who responds!

IF ANYONE HAS ANY QUESTIONS, COMMENTS, OR CONCERNS, I’D BE HAPPY TO ANSWER THEM!

1 Like

wait(0.001) is blazingly fast … try a task.wait() for longer.
The way this is scripted it is doing just what you told it to do. Basically a random click as is.
It needs a type of debounce …

local db = false
function trigger()
	if db then return end
	db=true
	------------- your code for this part
	if 
	else
	end
	-------------
	task.wait(1) -- play with this till you find what you want
	db=false
end

With these you shouldn’t need the wait()'s in the if else end.

or

local db = true
function trigger()
	if db then db=false
		------------- your code for this part
		if
		else
		end
		-------------
		task.wait(1)
		db=true
	end
end

This may not be the full solution, but your open variable seems to be using the value of a BoolValue instance based on the declaration on your 4th line.
You then treat the variable as just a boolean, when you should be treating it as a BoolValue, meaning any time you want to test the value, you do if open.Value == false then . . . and to set the value: open.Value = true

You also don’t need any waits within your trigger callback function, and I recommend that you set the size of your buttons to whatever they were before you tweened them when you make them visible = false, that way the tween effect works each time you open it.

Also, if you do suspect a part of your code to be the problem, you should really add a print in that section to show what your variables are set to

Are you joking, right?
wait() runs 30fps, while task.wait() runs >60fps. Why would you say task.wait() is longer?

I’m saying #1 use task.wait() #2 make the wait a bit longer. Not however you took that.

your language did imply what he interpreted

what does it say in the output?

I misunderstood lol :neutral_face:

Yeah, you can check it :smiley:

I guess it looks a bit confusing.

It doesn’t say anything sir. Thanks for asking.

You’re right, it’s in the trigger function

These Open variables are Value objects not boolean, so it should be

I think this is a boolValue.

Capture

I am using bool values to make them.

when you close make sure all sizes or whatever goes back to default and then when you press again it tweens back to the new size or position

All goes back to normal with this script:

local MainFrame = script.Parent.Parent.Parent.MainFrame
local drop = script.Parent
local menu = drop.Menu
local open = menu.Open.Value
local selection = drop.Selection

function trigger()
	if not open then
		menu:TweenSize(UDim2.new(1, 0, 6.238, 0), "Out", "Sine", 0.15, true)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = true
			end
		end
		wait(0.001)
		open = true
	else
		menu:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
		wait(0.001)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = false
			end
		end
		open = false
	end
end

selection.MouseButton1Click:Connect(trigger)

for _, button in pairs(menu:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseEnter:Connect(function()
			button.BackgroundTransparency = 0.8
		end)
		button.MouseLeave:Connect(function()
			button.BackgroundTransparency = 1
		end)
		button.MouseButton1Click:Connect(function()
			script.Parent.Parent.Parent.CurrentPage.Text = button.Text.." Buttons"
			trigger()
		end)
	end
end

But with the script I’m working with right now, It toggles the visibility property:

local MainFrame = script.Parent.Parent.Parent.MainFrame
local drop = script.Parent
local menu = drop.Menu
local open = menu.Open.Value
local selection = drop.Selection
local Frame1 = script.Parent.Parent.ButtonsDropdown
local Frame2 = script.Parent.Parent.FramesDropdown
local Frame3 = script.Parent.Parent.LightingDropdown
local Frame4 = script.Parent.Parent.IconsDropdown
local Open1 = Frame1.Menu.Open
local Open2 = Frame2.Menu.Open
local Open3 = Frame3.Menu.Open
local Open4 = Frame4.Menu.Open

local function closeFrames()
	for _, item in ipairs(Frame2:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame3:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame4:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
end

function trigger()
	if not open then
		menu:TweenSize(UDim2.new(1, 0, 6.238, 0), "Out", "Sine", 0.15, true)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = true
			end
		end
		wait(0.001)
		open = true
	else
		closeFrames()
		wait(0.001)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = false
			end
		end
		open = false
		Open2 = false
		Open3 = false
		Open4 = false
	end
end

selection.MouseButton1Click:Connect(trigger)

for _, button in pairs(menu:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseEnter:Connect(function()
			button.BackgroundTransparency = 0.8
		end)
		button.MouseLeave:Connect(function()
			button.BackgroundTransparency = 1
		end)
		button.MouseButton1Click:Connect(function()
			script.Parent.Parent.Parent.CurrentPage.Text = button.Text.." Buttons"
			trigger()
		end)
	end
end

Okay so open is a boolean but Open1 Open2 Open3 Open4 is a value object, dude read your script

Well @Sir_Pixelated, all of the Opens are all also Boolean Values, just in a different frames, does that change anything?

Just do

open = false
Open2.Value = false
Open3.Value = false
Open4.Value = false 

And you should be good to go

We shall see if you’re correct my friend!

Well, first of all it didn’t work, and now nothing opens after the first open.

Second of all, I’m going to bed since it’s like 9:00 P.M my time. Goodnight!

AND THANK YOU FOR ALL OF YOUR HELP AND SUPPORT SO FAR!