Hi! I had a question on how to access functions from other scripts.
Can anyone tell me how to access functions from other scripts? Because, I want to make a door that can be opened. But, when the game ends, the door resets. However, the door’s script and the game end script are different scripts.
A module script is basically a utility script. to start working with a module script, you need to do require(ModuleScript). each module script has to return something, and whatever they return is what you can use to access stuff about what it holds.
for instance:
say you have a module named 'Door`, and inside of it you have the following code
local Door = {};
function Door.Open()
print("opening door")
end
function Door.Close()
print("Closing door");
end
return Door
Now you can do the following from a different script:
local Door = game.Service.etc.Door;
local door = require(Door);
door.Open();
door.Close();
note this: a module script can return any value except i believe nil.