Discuss Scratch

DiamondEagle24
Scratcher
4 posts

Variables Not Working

I'm working on a more complicated game, and I created a variable, being Var1. When you would purchase a building in the game, Var1 would be set to 2, and I had a text box sprite that was supposed to pop up when that Var1 = 2. For some reason, the text box doesn't seem to be popping up. I did put a forever loop around it, and I checked to make sure Var1 was actually going to 2, and it seems it's a problem with the variable sensing in the if statement.
Here is the code:
when green flag clicked
forever
if <[Var1] = [2]> then
show
switch costume to [costume2]
if <key [r] pressed?> then
hide
end
if <key [n] pressed?> then
hide
end
if <key [g] pressed?> then
hide
end
else
hide
end
end

Sorry if this is something stupid I'm just missing. I'm having trouble with other variables, but I can't seem to work around this one.
Thanks!

Last edited by DiamondEagle24 (Jan. 29, 2018 18:06:09)

deck26
Scratcher
1000+ posts

Variables Not Working

Better to share the project as it's likely to be another script that's causing the problem.
DiamondEagle24
Scratcher
4 posts

Variables Not Working

Oh, sorry, I figured it out. I forgot to use
(These)

I was just being stupid. Thanks, though!

Powered by DjangoBB