Hi! I’m currently experimenting with module scripts and OOP, but I don’t quite understand certain aspects. I’m interested in creating a fighting game with abilities and during my research I found this thread: https://devforum.roblox.com/t/ability-system-using-module-scripts/600750/4 I read the code in the file attached in the answer I linked, but I didn’t quite get how it works. For example, in ServerScriptService there a script with just one line:
require(script.Parent:WaitForChild("Magic"))
But what’s its purpose exactly? If someone could break down the logic behind this method and explain it in simple\more practical terms I’d really appreciate it. Also, let’s say I wanted to let player select one magic type when they spawn and once selected, a GUI with the buttons binded to the abitilies appear, which are also keybinded to a keyboard key. How should I apply that method including UserInputService?
Thanks in advance to any person willing to help! And no, I’m not asking for someone to script it for me, but rather explain how I should approach it logic-wise. Pseudo-code also works!
ok so the single line of code does. n.o.t.h.i.n.g
if it has a variable to it, still nothing if it has ONE line of code, you'd need to actually access the module's scripts. an example:
script:
local module = require(module) module.access() -- This would then print "Hello World"
module script:
local module= {} function module.access() print("Hello world") end return module
as for userinputservice..
local UserInputService = game:GetService("UserInputService") function showgui() -- write the gui code here. end UserInputService.InputBegan:Connect(function(i) if (i.KeyCode == Enum.KeyCode.E) then -- you can change the key to press all you like showgui() end end)