Still Having Trouble with Broadcast Events and Passing Variables from Script to Script

I have gone over the Events.Broadcast API documentation a few different times now, watched vidoes, etc. but still have not been able to completely solve my problem . Once I remove the TICK piece of the function I cannot get anything to pass to the other script. I really don't need a constant check... at least it feels like I don't. So here is the scenario...

Script A has a variable called numberNeeded. I need to use that number at a certain time or in another function in script B. Is there a more simple way to send the number that doesn't have the TICK ? Or is the TICK the only way to really check.

What I think I am really after is an easy way to GET a custom component that is in another script easily. For example, if I was running the "Lobby Required Players" logic game component and wanted to know what the custom property value for "RequiredPlayers" is... what is the best way to snag that number?

Then secondly, if I can find a value in script A how do I broadcast that number to another script without using the tick... or again. Is that absolutely the way it gets there? Thanks for the help. This broadcast event thing has me the most confused in my journey so far.

I DO get that when I want to use broadcast simply it can be really great. IF thing A happens in script A then you can tell script B it happens and then it runs the function. Just the passing information between scripts is the thing that is getting me. Is there a particular tutorial out there that would demystify this for me? Thanks. Tried the Discord but was feeling like my questions were pretty dumb and I was wasting peoples time.

Thanks for the help!

It depends on what context your scripts are in. All server side scripts can reference each other and use .context.variableName to read variables and use functions so you dont need to use events to send anything.

If you're trying to send all players something, make sure Script A is in server context. You should be able to use

Events.BroadcastToAllPlayers("eventName", numberNeeded)

And on the client side script:

function OnNumberReceived(numberNeeded)
    print(numberNeeded)
end

Events.Connect("eventName", OnNumberReceived)

Another way is to make Script A networked and make the numberNeeded variable a custom property, that way client and server context can use GetCustomProperty(string propertyName)

Thanks for the answer @SausageChamp! I think I have a handle on the second way mentioned with broadcasts now or at least a little better after reading more and digging more after my post and then having you confirm it. I then figured out also the other thing you mentioned about networking, using custom props and GetCustomProperty. That actually ended up being the way I solved that piece. Worked like a charm.

I am not sure I get the first thing you mentioned. Can you clarify or show an example of what the syntax could be like. For example if I have a variable in scriptA and want to grab it from scriptB are you saying that I have write it like this in script B...

.scriptA.variableName

What is the "context" piece. Can you expand on that or where there are examples in the API or snippets or community content! That would be amazing. Thanks for trying to help me understand!

docs.coregames.com/api/contexts/

You can add a context folder by right clicking in hierarchy -> create network context