Identical code not working? (CLOSED)

Your username: tankt2016

What kind of device are you using?: iPad 6th gen, with the latest version of Hopscotch

1 sentence description of the problem (I was doing _________, and then __________ happened): I was coding. A few objects had to have the same code, so I just copy/pasted. But the copy/pasted code in one object didn’t work, but it did in the other objects.

Steps to make the problem happen:

  1. Copy/paste something
  2. It doesn’t work
    ….

I expected this to happen: Obviously I expected the code to run smoothly.

But instead this happened: But the code didn’t work at all.

Here’s a sweet screenshot: Not possible.

This isn’t the first time my code hasn’t worked…

5 Likes

What does the code look like or what is the code supposed to do?

2 Likes

It’s supposed to turn invisible when the Hide Options button is tapped in this wip.
When the Hide button is tapped, it uses a value to make the options invisible, and the decorations (those objects with the code) will not turn invisible if their X position is not 950.
It’s the one with the three stars that won’t go invisible when not moved from X 950.


2 Likes

Hmmm that is really weird. The only thing that might be causing it could be that “Start=1 >visi” could be forcing it to stay visible for some reason. But like you said, they all have the same code so maybe that wouldn’t make sense either. Here’s that block I’m talking about:


Is there any chance that this start= 1 block is repeatedly trying to force them to turn visible when at the same time they are all trying to turn invisible?
It’s a really cool project though, i hope it’s possible to fix this weird bug

2 Likes

It might be forcing it to be visible/invisible at the same time, but the other objects had that block too and they worked fine…

3 Likes

Maybe it is timed just right so that the first 2 seem to be doing the right thing while the last one is just off where it’s always visible. Is all it’s code in the exact same order as the first 2? It’s kinda a stretch but it could be it

3 Likes

Yep, unless the order of the rules counts.

3 Likes

Yes, they do count.
If you move the invisibility rule to the very bottom, it will go slightly after the rule which makes it visible, which will cause it to be invisible instead of visible.

7 Likes

Hm odd maybe that’s it.

2 Likes

Yeah probably.
Try changing that and if it still doesn’t work then maybe you could try rewriting the same code or something again

1 Like

It’ll work, I tested it.

3 Likes

K

1 Like

Oh that did work, thanks @MyPizza, @A_Metalhead, @Petrichor!

4 Likes

I didn’t do anything but okay, you’re welcome

1 Like

Yay! I’m excited to see the finished project! Hope you get featured for it

3 Likes

Maybe by rare chance the project thinks that the self variable is still referring to the other original object you copied from? Try rewriting the code manually and see what happens.

@tankt2016

1 Like

Oh wait never mind you guys already fixed it.

1 Like

I agree! Good luck with the project @tankt2016!

3 Likes

That’s odd

Need help?