Server Script not recognizing function in module script?!?

So I want to call a function from module script but the server can’t find it? Here’s the issue:

--Server script
print(quest,plr,currentTask)
local number = quest.Execute(plr,currentTask)

the line with quest.Execute errors “attempt to call nil value” and this is the prints:
image
as shown the function only shows on CLIENT.

module script (cut down):

module.Quests = {
	[1] = {
		Info = {
			["Objective"] = "Jump 50 times";
			["Amount"] = 50;
			["Reward"] = 120;
			["Folder"] = nil;
		};
		Execute = function(plr,folder)
			local success
	
			while task.wait() do
				local character = plr.Character or plr.CharacterAdded:Wait()
				local humanoid = character:WaitForChild("Humanoid")
				
				humanoid.Jumping:connect(function()
					success = true
				end)
				
				if success == true then
					success = false
					return 1
				end
			end
		end
			
	};

Any help is appreciated!

Show us the server and client and the module scripts

maybe in the module the function is written through ‘:’ and here through ‘.’ or vice versa

I added the module script. Here’s the server script. Local script is irrelevant since it doesn’t change anything in it.

local Players = game:GetService("Players")
local ts = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local mps = game:GetService("MarketplaceService")

local frame = script.Parent
local event = frame:WaitForChild("CreateTaskServer")
local deleteRemote = rs:WaitForChild("remotes"):WaitForChild("DeleteClient")
local createEvent = rs:WaitForChild("remotes"):WaitForChild("createQuestServer")

event.OnServerInvoke = function(plr,info)
	if plr ~= frame.Parent.Parent.Parent then return end
	
	local folder = info.Folder:Clone()
	folder.Parent = workspace
	
	for i,v in pairs(Players:GetPlayers())do
		if v~=plr then
			deleteRemote:FireClient(v,folder)
		end
	end
	
	return folder
end

createEvent.OnServerEvent:connect(function(plr,quest,currentTask)
	if plr ~= frame.Parent.Parent.Parent then return end
	print(quest,plr,currentTask)
	local number = quest.Execute(plr,currentTask)
	repeat task.wait() until number ~= nil and number
	
	createEvent:FireClient(plr)
end)
1 Like

Functions and threads cannot be sent through RemoteEvents or RemoteFunctions (even in tables), either from the server to a client or from a client to the server.

To fix your current problem, I would make a module script in ReplicatedStorage that stores all of the quests, then a client can tell the server which quest they went by referencing the quest’s index.

1 Like

Yes, I just remembered and did exactly this before this was posted. I will mark this as solution for people who get stuck.

You can send tables, but the received table is a copy of the sent table (not a reference to the sent table).