Hello everyone!
I would basically like to “call” a script, like how you would call a function. I would like to do that from another script. Is that possible?
Edit: Yes, I know about the Events, but i’d like to do without them.
Thanks
-Mehdi_ea
Hello everyone!
I would basically like to “call” a script, like how you would call a function. I would like to do that from another script. Is that possible?
Edit: Yes, I know about the Events, but i’d like to do without them.
Thanks
-Mehdi_ea
Hello there @Mehdi_ea,
As I know it is not really possible to call a script without Events. In addition there is a really non-suggested way to do it. You can check a BoolValue’s value. And if it changes to true. You can make the script work.
Events would be better if I had to use something like a boolvalue.
If it helped you to get the question can you mark it as solved? If you have something unsolved about this topic you can ask it here.
You could store your functions in the _G global table and call the functions from another script.
_G.Print = function(string)
print(string)
end
_G.Print("Hello world!")
Well I really discourage you from using _G about these because it is a really unstable way to do these.
So I’ve got a Discord DM from another DevForum member that can sadly not post and that told me to use ModuleScripts, and his idea fits my problem. Else, the answer is this post:
Thanks you to @qothiu for DMing me on Discord to tell me about the ModuleScripts.
Well yea, just an alternative to what you posted which is why i suggested it. Obviously its not the best practice, just an alternative.
It might be better to use BindableEvents in this case. Changing a BoolValue isn’t a great way to communicate between scripts.
Yes, I know about the Events, but i’d like to do without them
Events are still the correct way to do this without ModuleScripts tho.
Happy to help you @Mehdi_ea
@kinkocat I did suggest this method to his, but _G can only be accessed from the side its functioned and called upon, for example if you create a function on the server of _G it can only be accessed by the server, and he needed to be able to access a function from both, local and server scripts.
Yay, you can post!
Welcome to the DevForum: You Can Write edition!