Discuss Scratch

christianxyz
New Scratcher
100+ posts

If then block not work

the script was the condition was false:

when green flag clicked
if <(points) = [100]> then
broadcast [ win]
end
deck26
Scratcher
1000+ posts

If then block not work

christianxyz wrote:

the script was the condition was false:

when green flag clicked
if <(points) = [100]> then
broadcast [ win]
end
If you have a question please say what it is and, ideally, share the project.

Generally it doesn't make sense to check a value after the green flag is clicked and not after that.
bustedthumbs
Scratcher
100+ posts

If then block not work

The way this is written the check will happen only once and that once is at the very beginning of the program running.

What you probably really wanted was something like this -

when I receive [Points Changed v]
if <(points) > [99]> then
broadcast [win v]

Then every time you change the score make it look like this:

change [points v] by (5)
broadcast [Points Changed v]
lconaway
Scratcher
500+ posts

If then block not work

You should put a forever block around it, because like @bustedthumbs said, it will only check if the points equal 100 once. If you put a forever loop around it, it will continuously check whether or not the points have yet reached 100. Hope this helps!
bustedthumbs
Scratcher
100+ posts

If then block not work

I greatly prefer the way that I wrote it to using a forever block.

The use of forever blocks for situations like this can make your program get out of hand if it grows beyond a few simple scripts.
christianxyz
New Scratcher
100+ posts

If then block not work

lconaway wrote:

You should put a forever block around it, because like @bustedthumbs said, it will only check if the points equal 100 once. If you put a forever loop around it, it will continuously check whether or not the points have yet reached 100. Hope this helps!

bustedthumbs wrote:

I greatly prefer the way that I wrote it to using a forever block.

The use of forever blocks for situations like this can make your program get out of hand if it grows beyond a few simple scripts.

script:

if <(tempo) = [30]> then
play guitar (12) for (5) beats ::sound
end
lconaway
Scratcher
500+ posts

If then block not work

christianxyz wrote:

lconaway wrote:

You should put a forever block around it, because like @bustedthumbs said, it will only check if the points equal 100 once. If you put a forever loop around it, it will continuously check whether or not the points have yet reached 100. Hope this helps!

bustedthumbs wrote:

I greatly prefer the way that I wrote it to using a forever block.

The use of forever blocks for situations like this can make your program get out of hand if it grows beyond a few simple scripts.

script:

if <(tempo) = [30]> then
play guitar (12) for (5) beats ::sound
end
What? Is this a new script? I thought you said something different in the first post. Can you please explain? Thanks!
SuperSkull29
Scratcher
18 posts

If then block not work

My if statement didn't work when I tried to show or hide a sprite. Is it because I used pen?


Link here is you want to check it out. The problems are the sprites Flashlight and Ghost https://scratch.mit.edu/projects/792512483/

Last edited by SuperSkull29 (Feb. 16, 2023 01:33:57)

medians
Scratcher
1000+ posts

If then block not work

SuperSkull29 wrote:

My if statement didn't work when I tried to show or hide a sprite. Is it because I used pen?
Please make a new topic for this and post the link to the project in that new topic. Scratch 2.0 was still online when this was last posted on.

Powered by DjangoBB