What would you like the UI to do instead of overriding each other? There are different ways to go about this, my main ideas are:
A. You create a variable in order to tell you if there are tweens playing, if there are tweens playing, then simply increment the number at the top of the coin. Otherwise, create the clone and display it as normal. (Probably the best way to go about it)
B. Create a queue for the tweens that you want to play and play them after they are finished.
Your code seems to be right, but there could be other underlying things that might be interrupting the process.
But, have a look at my uncopylocked place, where I wrote the exact logic that achieves the exact thing you were trying to do, and it’s working correctly as you needed.
Examine my example and your game’s codebase and see where your logic needs to be tackled with a bit.
I’ve been busy so I couldn’t get to share it right away, sorry.
Thank you for taking the time to look into it more, and I believe I found the reason why!
I had rewritten some code to use .Completed:Wait() like yours for better optimization, and by doing that for both Tweens I have created, it works great. Here’s what I changed:
I always use that approach for things like that, so here’s the takeaway from it:
Connecting that tween upon completed event to a function was triggering it to happen, regardless of whatever tween, once you connected the “completed” event to the specific tween, the next time that event is triggered, the function inside it ran right away, overlapping both of your clonedGUIs…
I usually use .Completed:Wait() but the takeaway from this is, unlike the event, you are just waiting for the tween variable inside that function to be finished, so it’s like in a completely different thread-of-execution, so that’s the reason I use it and it makes sense for me to what I need to achieve at the moment.
Elaborating on the first takeaway, it’s simply happening because, imagine you have like CharacterAdded event, if you connect it to a function, it will trigger as many times as your character is reloaded.
It’s sometimes not easy to spot these little things right away, haha! Good job!