Static Variables Cannot Be Used in Other Script

When I’m declaring my block number as zero in loosecollider(I chose it to do the fix) I get this error. Same code usage is not an issue in course. What can I do?


The Error is:
static member cannot be accessed with an instance reference…


You need to use the class not the instance of the class. So, in this case, use;

BrickShot.BlockNumber = 0;

Note, the capital “B” for the class as opposed to your lower-case “b” for the private variable at the top of your code example.

Note, you can just paste your code into your forum posts, this is much easier than screenshots as it enables those who respond to copy and paste parts of it back for you to see.

See also;

1 Like

Thanks Rob, You’re golden :raised_hands:

I’ll keep in mind your warning too :sweat_smile:

1 Like

Hehe, you’re very welcome :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms