Module script doesnt see a function

I want to use module scripts function in a another function. But it seems like it doesnt see the function

function Zombie.Movement(zInfo,clientInfo,ZombieInfo)
	local num = 0
	RunService.Heartbeat:Connect(function()
	if num < 1000 then
			clientInfo.Position = zInfo.Position + Vector3.new(math.random(0,0.3),0,0)
			ReplicatedStorage.ZombieClient:FireAllClients(clientInfo)
		end
	end)
end

function Zombie.Spawn(Zombie,path, startingpoint)
	--Script(its everything ok with it)
	wait(0.1)
	Zombie.Movement(zInfo,clientInfo,ZombieInfo)
end

image
i tried to do it in couroutine.wrap but it printed: invalid argument #1 expected function got nil

Looks like you might potentially have some shadowing going on here.

function Zombie.Spawn(Zombie,path, startingpoint)
	--Script(its everything ok with it)
	wait(0.1)
	Zombie.Movement(zInfo,clientInfo,ZombieInfo)
end

Notice how you’re passing in Zombie as a parameter to this function? If that Zombie isn’t the same as the object Zombie which the function Zombie.Movement is a function of then you’ll get that error.

How are you calling Zombie.Spawn(...)?

1 Like