How to compare the positions of the children in a folder

Hey, I have just recently tackled rhythm games and I am attempting to make an OSU mania type minigame and just needed help understanding how I can get the script to track the upcoming note, not the ones that follow. I got the game working, it’s only that when I hit a key all present notes in that column are being affected, which is obviously not what I want.

I have thought of a solution, which is using a :GetChildren() on the folder holding the notes for that column, and determining which note is the closest to the destination. After hours of trying, I don’t know how to do this, so if you have a possibly better solution or know how to execute this one then your help will be greatly appreciated.

Like this.

for _,v in {Iterate} do
	for _,d in {Iterate2} do
		if v.Position == d.Position then
			--
		end
	end
end

I am trying to see which child in one folder has the greatest Y scale value, while they all have the same names, I don’t think I would be using a “==” to achieve that.

You’ll need one variable that’ll store the object with the highest value.
When you loop through the children (objects) of the folder, you will want to compare the current object you are iterating over with the stored object in the variable.
If the current object is greater than the object stored, or there’s no object currently stored, store the object being iterated over inside the variable. Here’s an example:

local greatestObject
for _, object in folder:GetChildren() do
    -- Example: if object.Something > greatestObject.Something then ...
    if not greatestObject or --[[Compare the values here]] then
        greatestObject = object
    end
end
1 Like