If statements dependant on conditionals in another script

I looked around for solutions but none were clear for me and I’m very new to programming.

How would I write if statements when the attribute(s) being compared are declared and manipulated in different scripts.

In my project I’m programming a betting board. Players will choose one of 3 chips by clicking said chips icon on the screen. For this I’ll use the red chip as the example. Clicking the chip will turn a Boolean attribute named “redclicked” equal to true, to show it’s been selected. Then a red-chip should appear on the board tile selected by the player. When a tile on the board is clicked a function runs to check which chip has been selected, in this case, if redclicked = true then the chips icon should appear on the board. This of course doesn’t work because the if statement can’t check if redclicked is equal to true or not because it’s in another script.

What type of solutions are available to fix this?

6650506--759703--upload_2020-12-22_18-40-46.png

If you posted your code directly to the forum using CODE tags, instead of posting images, people could just edit your code for examples. But all you need is a reference in ImageClick to the instance of ChipChooser. You’d set the reference using the inspector, any of the Find methods, or however you want them to find each other.

public ChipChooser MyChipChooser;

Then you just check redclicked on that reference, since you already have redclicked declared as public.

if (MyChipChooser.redclicked == true)
3 Likes