Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Variable problems
- Kitten_Boy_10
- Scratcher
12 posts
Variable problems
Hi everyone! So I was working on my new game called The game about your random life choices, when, I was trying to make a variable be set to 15 when the sprite was clicked but then it got set to 16 so nothing would appear. Then I made it so they would appear when the variable was 16 but it still wouldn't appear. Here is the code if you would like to look at it.
Just to say it, I made 3 main sprites. A button that is on the left, one in the middle, and one on the right. It is on the far left sprite. So it senses what the ButtonClicked variable is so it can change costumes and hide or show them.
The code would look like this.
when this sprite clickedThen it says that the ButtonClicked variable is 16 instead of 15.
if <(ButtonClicked) = [14]> then
set [ ButtonClicked] to [15]
end
Just to say it, I made 3 main sprites. A button that is on the left, one in the middle, and one on the right. It is on the far left sprite. So it senses what the ButtonClicked variable is so it can change costumes and hide or show them.
The code would look like this.
when green flag clickedThe reason I have the variable is because I don't want to make hundreds of messages and then it would just get crowded.
if <(ButtonClicked) = [15]> then
switch costume to [This Random Costume]
Last edited by Kitten_Boy_10 (March 27, 2024 21:19:02)
- PhiPhenomenon
- Scratcher
500+ posts
Variable problems
There isn't anything wrong with the script you posted, so there's probably another script that's interfering with it. Can you share your project and link it here?
- Kitten_Boy_10
- Scratcher
12 posts
Variable problems
Sure! There isn't anything wrong with the script you posted, so there's probably another script that's interfering with it. Can you share your project and link it here?https://scratch.mit.edu/projects/959299469/
- Kitten_Boy_10
- Scratcher
12 posts
Variable problems
Oh. I just tested it and it works. It might've been a problem I had fixed and not tested before I put this out. Sorry for wasting your time.
- PhiPhenomenon
- Scratcher
500+ posts
Variable problems
No worries =] Oh. I just tested it and it works. It might've been a problem I had fixed and not tested before I put this out. Sorry for wasting your time.
- Kitten_Boy_10
- Scratcher
12 posts
Variable problems
Wait, nevermind, when I added it to make the ButtonClicked variable change to 16 when it's clicked, it started the problem again. Aren't weird problems just GREAT? Oh. I just tested it and it works. It might've been a problem I had fixed and not tested before I put this out. Sorry for wasting your time.
So this is what I did with the variables if you would like to know. When it would be set to 15, it would be set 16 btw
when this sprite clicked
if <(ButtonClicked) = [14]> then
set [ButtonClicked] to [15]
end
if <(ButtonClicked) = [15]> then
set [ButtonClicked] to [16]
end
I'm just going to sleep for a while. I've been trying to fix this for an hour now so…
Last edited by Kitten_Boy_10 (March 27, 2024 21:32:03)
- Discussion Forums
- » Help with Scripts
- » Variable problems