-
What do you want to achieve?
I’m making a fighting game with a class system, each classes specific move functions are located in module scripts for each one. I want to index a table with the required module scripts and its appropriate movement function. -
What is the issue?
The function index does execute the function, but it doesn’t send the data given from the function call, to the function.
Server Script:
local repStor = game:GetService("ReplicatedStorage")
--ClassModules
local classModuleFolder = repStor.Modules.Combat:WaitForChild("ClassModules")
local tempClassModule = require(repStor.Modules.Combat.ClassModules:WaitForChild("Guardian")) -- for testing
local classes = {}
for index,module:ModuleScript in pairs(classModuleFolder:GetChildren()) do
classes[module.Name] = require(module)
end
--Bindables/Remotes
local combatDir = repStor.Events.Combat
local executeMove = combatDir.ExecuteMove
executeMove.OnServerInvoke = function(plr:Player, move:string, class:string)
coroutine.wrap(function()
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
classes[class][move](plr)
end)()
end
Module Script:
local moves = {}
local repStor = game:GetService("ReplicatedStorage")
local combatInfo = require(repStor.Modules.Combat:WaitForChild("CombatInfo"))
function moves:hit1(plr:Player)
local char = plr.Character
local rightArm = char:FindFirstChild("Right Arm")
combatInfo:hitBox(char,rightArm.RightGripAttachment,Vector3.new(2,2,2),true)
end
return moves
Any help would be greatly appreciated.
