How do I stop a function from running while another function is?

Can you explain how to do this? Sorry if I don’t really understand.

You should to organize the numbers into a table. It is much more efficient and easy to access.

This is how I would set my UI.

local TWEEN_INFO_EXP1 = TweenInfo.new(.1, Enum.EasingStyle.Exponential)

local ANIMATION_CONSTANTS = {
	Stroke_MouseButton1Down = {
		["Btn"] = {
			TweenInfo = TWEEN_INFO_EXP1,
			Values = {
				Size = UDim2.fromScale(.08,.099),
				Position = UDim2.fromScale(.942,-.029),
			},
		},
		["TL"] = {
			TweenInfo = TWEEN_INFO_EXP1,
			Values = {
				Size = UDim2.fromScale(.159,.185),
				TextSize = 75,
				Position = UDim2.fromScale(.495,.5),
			},
		},
		-- do for all tweens inside of an event
	},
	
	-- do for all events
}

-- build an interpreter to read the table and execute
local function executeTweens(tweenEvent)
    -- find the table entry and run all tweens
end

executeTweens("Stroke_MouseButton1Down") -- run it inside an event
2 Likes

Just correct me if I’m wrong,

So local TWEEN_INFO_EXP1 = TweenInfo.new(.1, Enum.EasingStyle.Exponential) is the variable that is the pre-made tween so we don’t have to keep creating new tweens.

And local ANIMATION_CONSTANTS = { is the table of our UI elements and how we will set their values in the tween

And this is the table for the Stroke.MousebuttonDown function and has the values for all the UI elements JUST for that one function

Stroke_MouseButton1Down = {
		["Btn"] = {
			TweenInfo = TWEEN_INFO_EXP1,
			Values = {
				Size = UDim2.fromScale(.08,.099),
				Position = UDim2.fromScale(.942,-.029),
			},
		},
		["TL"] = {
			TweenInfo = TWEEN_INFO_EXP1,
			Values = {
				Size = UDim2.fromScale(.159,.185),
				TextSize = 75,
				Position = UDim2.fromScale(.495,.5),
			},

And then I keep repeating this for every function?

		},
		},
		-- do for all tweens inside of an event
	},
	
	-- do for all events
}

And I don’t get what this means

 build an interpreter to read the table and execute
local function executeTweens(tweenEvent)
    -- find the table entry and run all tweens
end

executeTweens("Stroke_MouseButton1Down") -- run it inside an event

Just trying to understand how this works sorry if I’m bothering you too much.

Oops some of the code I put didnt get put into my response let me edit.

I’m going to leave it here. This is getting off topic from the original post.

Your UI is doing good as it is. Don’t worry about setting up complicated systems if it’s too hard. You will eventually know how to do it. Focus on getting the rest of your game working.

No, it’s for reusing the same TweenInfo you use for most of the tween creates

Yes

The ANIMATION_CONSTANTS table contains the states of each UI. When you enter a state, such as Stroke.MouseButtonDown, all listed tweens are handled.

You need to build your own function that reads the table and executes it.

I think you still have a lot of knowledge gaps before you can implement a more complicated UI system. Master your basics then feel free to look up tutorials for better systems!

1 Like