I have a script called "End" in a model in workspace. I have a script called "Generate" in server script service. How can I have these two scripts "communicate" with each other so that I can integrate it into my onTouched event in the end script?
Communicating from Script to Script???
2 answers
You could use a BindableEvent, which has the ability for scripts to talk to one another upon event. Here's an example.
local Bindable = Location_Of_Bindable.BindableEvent;
wait(1);
Bindable:Fire("Hello World!") -- Fires the bindable with the argument
And, within a second script.
local Bindable = Location_Of_Bindable.BindableEvent;
Bindable.Event:Connect(function(Str) -- Listens to be fired
print("Message sent:", Str); -- Prints what was given when executed
end)
The second code should print Message sent: Hello World!
Stuff talked about
Stuff related, but not talked about
2. BindableFunction - Basically uses a function for when called upon. Think of these as remote, but for their respective sides. (Server-To-Server, LocalScript-To-LocalScript (same client only though))
Apologies if this wasn't "high quality", I haven't post an answer in months. Regardless, I hope this helped. :)
If you have any questions, please don't hesitate to ask. :D
use _G like: script1:
_G.variable = "Hi"
script2:
print(_G.variable)
OUTPUT: "Hi"
[EDIT] or Modulescript:
local box = {
["Variable1"] = "Var1",
["Variable2"] = "Var2";
}
return box
script:
local Variable_box = require(game.Workspace.ModuleScript)
function printall()
for i, v in pairs(Variable_box) do
print(v)
end
end
--function
printall()
output: Var1 Var2
3 comments
i use _G oftentimes
G is slow. Module scripts slow you to keep track of variables/ functions between scripts
and if i not want to use _G, i use require()
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
happy first-post-in-months post
bro, events are bitly harder than require or _g, but you want rep too :\
Don't make idiotic comments, gloveshun.
^
That's awful and sad. :/ You can't post answers w/o someone thinking that's "they're gonna get rep for it".