Sending a require module to a server

I want to send a function from a require on a module script, but when the server gets it it just equals nil and cant be used when fired to the other clients, is it even possible to send this?

here in the first script

m1 = require(modulescript.m1)
local  data = {action = "weaponattack", char = character, attack = m1}
remote:FireServer(data)

here in the server

remote.OnServerEvent:Connect(function(p, data)
	 if data.action == "weaponattack" then
		 for i,player in pairs(game.Players:GetChildren()) do
			remote.weaponevents:FireClient(player, data)
		end
	end
end)

here back in the local script

remote.weaponevents.OnClientEvent:Connect(function(data)
	if data.action == "Rweaponm1" then
		data.attack.m1(data.char)
	end
end)

Why can’t you just require it in the script?

because I want it to be on sent to another player to do the module

What exactly are you trying to achieve with this? What does the ModuleScript contain that needs to be sent?

I was trying to send attack data to have the attacks effects be replicated on another players screens, but I found another method to do this, but if u got an answer for this problem I still would like to know

You could send the name of the module script and have all of those inside of a folder, then require the child with that name

1 Like