Colored MovieClip Counter

First of all hello to everyone in the community. I am new here, learning Wick Editor and coding general. I am using Version 1.19 on a Mac and got stuck trying to make a sliding, drag-n-drop type of a game using some code snippets from the forum.

I have several clips, objects or shapes which i am able to color upon clicking but, i would like to have a counter for each color which tells me how many clips or shapes have the same color using the setText function.
Since i could not register an account, i asked ChatGPT which kept on giving me different versions which confused me a lot and did not achieve what i was intending doing.

However, some of the code it gave me kind of worked but it was counting colors from my colorObjects which i use to color clips with and could not figure out how to change it from colorObjects to my mcArray.

Unfortunately as a new user i can not attach a file would really really appreciate any feedback.

And, apologies for texting long.

Thanks…

Hey there! If copying scripts and arrays are getting confusing, try classes! I’ll be posting a class tutorial soon!

Hi noobfield

Thanks for your response, i saw your Javascript Classes post which i hope will help newbies like myself learn a thing or two about JS but i am not sure how Classes differ from Arrays and or, if it would help me achieve counting clips with the same color on a window or better said, page? If yes, i will certainly be happy to learn how.

Regards,

The thing is: you can make a custom class that covers a Wick.Clip and make an array full of them.

Or even better, make a class which runs the code, than has a method to get the clips!

i’ve set your account so that you should be able to upload stuff. if you want to show us the project we should be able to help.

by the way, if you are using the desktop version, i actually suggest you go to wickeditor.com/editor or wickeditor.com/test to get the most recent version, since the desktop ones are outdated. also, chatgpt is not going to give you very useful information because the internet doesn’t really have enough training data on wick editor.

True, for 99.99% of the internet, this is some random website them never heard of before.

Btw, @BaronAWC, the github linking feature on profiles here is broken!

facebook and twitter don’t work either, and unfortunately i have no idea how to fix it. (i’m not gonna bother disconnecting my google to see if that one is broken too)

i guess they exoired or smth

Wow…!
Thank you so much, much appreciated and attached is the my file which has an almost working example but for some reason it won’t stop counting on most colors.

Thanks once again and, regards.

ClipCounter2-11-2025_14-51-09.wick (147.7 KB)

ClipCounter2-11-2025_14-51-09.wick (147.7 KB)

Actually, i think facebook can be recovered with a dev account, and github?.. i found the documentation for that.

i highly doubt i have the administrative powers to actually fix it though…

It’s stuff you configure on the forum’s Discourse config page (which even ROBLOX uses nowdays).

this shows up when i try coloring the first one of the 5 circles in a row, so i guess let’s fix this one first.
image

the error you are running into (other than the typo) is that you are trying to use your xCount variables when they are no longer in scope. by that, i mean that you defined them in the default script of a frame by using var xCount = [...], but as soon as that script is finished running, those variables are destroyed. so when you try to use them again, the code doesn’t know what to do.

to make sure variables do not get destroyed after the script is done, there are a few ways to do it. for this case, i think project.xCount is the best way to do it. this makes the variable’s scope the project, which means your variable will never be deleted for the duration of the project running.

the syntax for this is slightly different than other variables. to define the variable, do something like project.myVar = 5;. note that you don’t need to put var in front or anything like that. to access the variable, just do project.myVar again.

in your project, it kind of looks like you want the xCount variables to persist, so here’s how i would define your redCount as an example. and then, for every time you use redCount, turn it into project.redCount.
image

i don’t think this will fully solve your issue but it should help progress to what your actual problem is.

You can use any object which persists between sandboxed functions.
Here’s the ones i know of:

window // not useable...
this // usable, accessible in other scripts referencing it.
project // usable, persists in all scripts with extreme ease (could be bad...)
Wick // Unknown and accessible too!

It makes absolute sense especially if the variables need to be accessible through out the project and not only once. I remember using “window.” on colorCounts (e.g window.redCount) but had different version of everything at the time and could not really tell what worked and didn’t. And as of redCount+1; i just wanted to see if the counter was going to respond different if i changed it from redCount++; to redCount+1. I will make some changes as suggested and feedback as soon as i get a moment and again, thank you so much for pointing out all this.

And, i came cross this, https://discussions.unity.com/t/count-objects-with-specific-colour/98503 which i will give it a shot and see if it works…