Discuss Scratch

bool227
Scratcher
14 posts

Variable not changing

Hey! so iv'e programmed it so that is a projectile hits a player, the hit counter goes up. however the hit counter remains as 0. Any reason why?

This is my project: https://scratch.mit.edu/projects/549664037/
Thingied
Scratcher
1000+ posts

Variable not changing

The problem is that the clone(s) don't get change to ever get to the forever loop. It just glides to the other side and delete's itself. Best way to fix this is to move the counter changer script to a different loop. That way it'll check if it's touching the heart when it's gliding.
bool227
Scratcher
14 posts

Variable not changing

Yay! it works now!!!
kittensu
Scratcher
53 posts

Variable not changing

Okay, I'm able to help with this. First you want to go to events and get the “when flag icon clicked” block, then to motion and get the “go to block.” connect
them together and here are the next steps: Take another “when flag icon clicked” block, and now go to “control” and get an “If then” block. connect them
together, of course. Now, go to sensing and take a “if touching” block. Click it where it has the *if touching mouse pointer.“ it will have a triangle beside it. Just click the icon, and click the name of your sprite instead of mouse pointer to work the game. Put the if touching block instead the blank spot of the ”if then“ place. Then, go to the variable section and make a variable. For an example: I'd just call it ”score.“ then, take the ”CHANGE score by one block.“ There will be a triangle and another variable, just do the same in ”if touching“ block. Make sure you don't take the ”SET“ block, its the change block. Then put the change block inside the blank space after the ”then“ in the ”if then block“ Also, go to events and get the flag icon block, go to variable and select ”set score to zero" So the score resets when the flag is clicked again.
bool227
Scratcher
14 posts

Variable not changing


Oh wait, it's still broken.
Added it to a different loop called when i receive dodge1 but it still doesn't work.
Also the music is broken.
bool227
Scratcher
14 posts

Variable not changing

kittensu wrote:

Okay, I'm able to help with this. First you want to go to events and get the “when flag icon clicked” block, then to motion and get the “go to block.” connect
them together and here are the next steps: Take another “when flag icon clicked” block, and now go to “control” and get an “If then” block. connect them
together, of course. Now, go to sensing and take a “if touching” block. Click it where it has the *if touching mouse pointer.“ it will have a triangle beside it. Just click the icon, and click the name of your sprite instead of mouse pointer to work the game. Put the if touching block instead the blank spot of the ”if then“ place. Then, go to the variable section and make a variable. For an example: I'd just call it ”score.“ then, take the ”CHANGE score by one block.“ There will be a triangle and another variable, just do the same in ”if touching“ block. Make sure you don't take the ”SET“ block, its the change block. Then put the change block inside the blank space after the ”then“ in the ”if then block“ Also, go to events and get the flag icon block, go to variable and select ”set score to zero" So the score resets when the flag is clicked again.
ill try dat
kittensu
Scratcher
53 posts

Variable not changing

Make sure not to put “play sound” instead put the “start sound” block. Because the players would have to wait until the sound played, and then play the game. But you want the music to start while playing the game, right? Or, make sure to put the repeat block and not the forever block. I don't know if It's me you're replying to, but I made a reply about your game. Your variable was not changing, correct??
bool227
Scratcher
14 posts

Variable not changing

ok. im dumb. i made the wrong loop. works now. thanks all!
bool227
Scratcher
14 posts

Variable not changing

kittensu wrote:

Make sure not to put “play sound” instead put the “start sound” block. Because the players would have to wait until the sound played, and then play the game. But you want the music to start while playing the game, right? Or, make sure to put the repeat block and not the forever block. I don't know if It's me you're replying to, but I made a reply about your game. Your variable was not changing, correct??
you both are lifesavers. also fixed the bones coming after the death animation.
kittensu
Scratcher
53 posts

Variable not changing

No problem, lol
bool227
Scratcher
14 posts

Variable not changing

This scrpit is sooo messy lol. im not good at drag n drop. Im a fullstack web dev
kittensu
Scratcher
53 posts

Variable not changing

Yeah, my scripts are also really messy
bool227
Scratcher
14 posts

Variable not changing

bruh sound and bones are still not working. The bones come later as well and the sound is stopping cuz i added a stop all sounds…. fix plsss. i was planning to make make this a full release. No chance of that…
kittensu
Scratcher
53 posts

Variable not changing

I may have not explained that correct but the code is: when flag icon clicked start (whatever sound) and get a repeat block and put the sound in the blank space of the *repeat block*
bool227
Scratcher
14 posts

Variable not changing

Yea. but the two soundtracks overlap each other
MasterofTheBrick
Scratcher
1000+ posts

Variable not changing

Set the volume to 0 on the sprite in which you want the music to be stopped, instead of stopping all the sounds currently playing in the project.

Last edited by MasterofTheBrick (July 1, 2021 08:04:50)

bool227
Scratcher
14 posts

Variable not changing

ok. here we go. the end sound is looping now but its not overlapping with the other one. also the bones keep coming no matter what i do. Not even stop all other scripts is sprite does the job…
MasterofTheBrick
Scratcher
1000+ posts

Variable not changing

bool227 wrote:

ok. here we go. the end sound is looping now but its not overlapping with the other one. also the bones keep coming no matter what i do. Not even stop all other scripts is sprite does the job…

So is the sound resolved? I thought preventing them from overlapping was what you wanted, as per post 15.

bool227
Scratcher
14 posts

Variable not changing

true true but now the sound plays until a certain part and then loops it and it sounds like a stuck cassette
MasterofTheBrick
Scratcher
1000+ posts

Variable not changing

bool227 wrote:

true true but now the sound plays until a certain part and then loops it and it sounds like a stuck cassette

Then either set the volume to 0 or use a variable to control the repeating of the sound.

repeat until <(var) = [stop]>
play sound [ v] until done
end

Powered by DjangoBB