I made a play button and it’s not working
Just use stop() and play()
The image says:
if(project.pause=true){
project.stop();
}
if(project.pause=false){
project.play();
}
You should use “===
” instead of one “=
”
One equal sign is used when setting a something equal to something else, three equal signs are used to see if that thing is equal to that other thing.
I’d also recommend using “else,” but you don’t have to
if(project.pause===true){
project.stop();
}else{
project.play();
}
Something like this could also work
if(project.pause)
project.stop();
else
project.play();
@Hamzah_Alani I tried to make the code work but it doesn’t work :/
Togle.wick (2.5 KB)
The function only plays the animation but does not pause it.
This is because “project.pause” isn’t defined, so instead it returns a “false” value since the variable doesn’t exist.
I changed the code a bit so that if the button is clicked on, project.pause is set to true when the project pauses and is set to false when the project plays. This way the button works more properly.
I also moved this to the “mousepressed” script because when using the mousedown script the user might at times hold their mouse down for a second or two longer, therefore running the script more than once and in doing so playing and pausing the project with a “click,” making no difference.
Try it:
Togle.wick (2.5 KB)