#trying to get part to change color every time it's touched but only in intervals of 2 seconds

1 messages · Page 1 of 1 (latest)

zinc birch
#

even with waits added it just appears to fire the color change script rapidly

chilly lotus
cold vault
#

add a debounce variable

chilly lotus
#

what exactly do you want the script to do?

zinc birch
#

everytime it's touched just to have it change in intervals of like 1-2 seconds

#

not give u epilepsy

chilly lotus
#

or change every 2 seconds

zinc birch
#

so like touch -> color change -> wait -> touch -> color change -> rpeeat

zinc birch
#

like theyd have the same effect?

chilly lotus
#

no that's different

#

in programming you tell the computer exactly what to do

#

so it could either be that the part changes color when it's touched

#

and if it's touched after less than 2 seconds it does nothing

#

and after that it doesn't change color until it's touched again

bleak plinth
#

This could kill someone!!!!

chilly lotus
#

or it could be that it's touched and it changes color every 2 seconds forever

zinc birch
#

ohhh

short meadowBOT
#

studio** You are now Level 2! **studio

chilly lotus
#

i can't tell what you want

bleak plinth
#

Epilepsy attacks are no joke

zinc birch
#

the desired effect is that when you touch it it changes color but the color only changes every 2 seconds and like

#

if you leave it be it remains @ that same color

chilly lotus
#

@bleak plinth stop ❌ reacting me

chilly lotus
#

so here you make a variable named debounce

zinc birch
#

whats a debounce?

chilly lotus
#

when the part is touched, debounce is set to true

#

while it's set to true, if it's touched then it exits the code block using return

#

and then after 2 seconds it's set to false again

cold vault
chilly lotus
#

and if it's false, the code block isn't exited and the part changes color

cold vault
#

its just a variable to keep track of whether you can change colour again

zinc birch
#

alr thx yall this is very helpful i'll mess around w/this more & close the thread

bleak plinth
#

Why did bro make it sound so complicated? Its a fucking debounce bro

chilly lotus
#

instead of copy pasting from tutorials

#

mindlessly

bleak plinth
#

Yeah, but no need to explain the it returns if it is true and then it is ser to false after .2 seconds or whatever cooldown ur talking abt

warm comet
#

You have to add print(“cool”)

short meadowBOT
#

studio** You are now Level 1! **studio

cold vault
#

btw im pretty sure using .Random is better

#

idk the logic behind it but I’ve heard it is

chilly lotus
bleak plinth
#

Bruh stop glazing

#

I been scripting too

cold vault
#

why are u complaining about someone explaining code 😂

#

what’s so bad about explaining what each line does

bleak plinth
#

But I aint a nerd that says «umm acually🤓 it sets the variable to tru wich returns it later if clicked»