With ModuleScripts, you can organize scripts clearly in Roblox and easily share functions between server and client. This way, you avoid duplicate code and make your project easier to maintain.
How to do it:
With ModuleScripts, you can structure your Roblox code cleanly and collaborate better.
-- ModuleScript in ReplicatedStorage
local Modul = {}
function Modul.begruessung(name)
return "Hallo, " .. name .. "! Willkommen im Spiel."
end
return Modul
-- ServerScript or LocalScript
local modul = require(game.ReplicatedStorage:WaitForChild("Modul"))
print(modul.begruessung("Spieler")) -- Outputs greeting