Answered by
6 years ago Edited 5 years ago
You can share variables through many ways. The one I use more is through global variables (_G), which they store a variable globally, bring accessed through many scripts. An example would be this:
2 | _G.variableName = "Nathan" |
Then another script
Another way are the Bindable Events/Functions, which are normally used for triggerers in the server. They can only be used through server scripts, if you want to communicate through Server - Client, use RemoteEvents
or RemoteFuncttons
. An example can be this one:
2 | local event = game:GetService( "ReplicatedStorage" ):WaitForChild( "BindableEvent" ) |
4 | function onClicked(value) |
5 | local value = script.Parent.Money.Value |
9 | script.Parent.MouseClick:Connect(onClicked) |
BindableEvent
2 | game.ReplicatedStorage.BindableEvent.Event:Connect( function (value) |
I don't know well how does a bindable event work, as I normally use _G values, but hope this works! Please accept the answer if it helped.