Tween Interrupting Each Other (Debounce Help)

I have an ambient change but if you leave and come back in the touched part, the script/tween breaks, so I’m wondering if through debounces it could get fixed. I was thinking that by making 2 debounces for the Touched & TouchEnded, the script won’t run multiples per every hit enter & exit. That’s what I at least think is the problem, because once I enter the zone it runs only once, but once you leave, the TouchEnded runs 7 times, therefore the tweens interrupt each other pretty well.

bc6ddf73d85fa74f49ed10ea7bf0c2c3

add a

if not debounce then return end

before setting the debounce to false.

1 Like

I think I did try to do that last time, but let me check out if it works…

So yes, it works, but now I have a problem… I have no idea why the tweens don’t work now. Only the Entering one works, but not the leaving one

That’s weird. Try printing

print(not debounce)

it should print false (inside of the TouchEnded)

1 Like

You’re right, maybe it’s not the debounce anymore, but the tweens?

edit: My question is how? if the tweens worked fine with bad debounces? XD

edit2: So— Once I enter again, the “leaving” tween plays as “entering” weird as heck

edit3: So- I made some prints statements, and once I enter, it also marks the leaving
bc0213cfce5d8dd172fc6a6dccd440e7

I would assume something is mixed up on the client script

This is another thing that happened:
I entered, it said I’m out, then I entered again… and it changed the lighting
971352434b198a3b4e3396646cd18ada

So yes, something is definitely mixed up on the client script, It does send “In” and “Out”, so it should be able to specify?

1 Like

Fixed it, it was just the position of some script line, there was a line that checked if the area had sound before checking for all ambientParts as well before setting the tween goals. Hope what I just said is understandable :rofl:

Thank you so much!!! I really appreciate your time and effort… have a great day

1 Like