Cant require a script?

image
Invalid arguments??
Should work perfectly fine
I am requiring the script to start that script

The script that cant be required:

local module = {}

module.start = function(owo)
	print("Tread Starting")
	local player = game.Players:GetChildren()[1]
	local model = workspace[player.Name]
	local Humanoid = model.Humanoid
	local root = model.HumanoidRootPart

	---Settings


	local AttractionDistance = 120
	local LurkUntil = 20
	local Damage = 25



	----
	local pathfindingservice = game:GetService("PathfindingService")

	function computepath(Pos1,Pos2)
		local path = pathfindingservice:CreatePath()
		local suc,e = pcall(path:ComputeAsync(Pos1,Pos2))
		if suc then
			return path:GetWaypoints()
		else
			return nil
		end
	end

	function distance(pos1,pos2) return (pos1 - pos2).Magnitude end

	function GetChar()
		return workspace[game:GetService("Players"):GetChildren()[1].Name]
	end

	function maintread()
		local target = nil

		while wait(.1) do

			if target then
				local TargetChar = GetChar()
				local Distance = distance(TargetChar.HumanoidRootPart.Position, script.Parent.HumanoidRootPart.Position)


				if Distance > AttractionDistance then
					target = nil
				else
					local waypoints = computepath(TargetChar.HumanoidRootPart.Position, script.Parent.HumanoidRootPart.Position)
					if waypoints == nil then return print("Cant reach target") end

					Humanoid:MoveTo(waypoints[1])
					Humanoid.MoveToFinished:Wait()


				end
			else

			end

		end
	end
end

return module

the script that is calling the require

local EntityStorage = game:GetService("ServerStorage").EntityStorage
local EntityCap = 50
local CurrentEnities = 0
wait(5)
local player = game.Players:GetChildren()[1]
local root = workspace[player.Name].HumanoidRootPart

local AvaibleEntities = {"smiler", "skin-stealer"}

function SpawnEntity(EntityType, Vec3)
	local NewEntity = nil
	pcall(function()
		NewEntity = EntityStorage[EntityType]
	end)
	if NewEntity ~= nil then
		CurrentEnities = CurrentEnities + 1
		NewEntity = NewEntity:Clone()
		NewEntity.Parent = workspace.Entities
		
		NewEntity:SetPrimaryPartCFrame(CFrame.new(Vec3))
		local scr = require(NewEntity.ai)
		scr.start("yes")
	end
end

function treadmain()
	while true do
		wait(5)
		for _,v in pairs(workspace.Entities:GetChildren()) do
			local mag = (root.Position - v.HumanoidRootPart.Position).Magnitude
			
			if mag > 300 then
				CurrentEnities = CurrentEnities - 1
				v:Destroy()
			end
		end
		
		if CurrentEnities ~= EntityCap then
			local x = math.random(-200, 200)
			local z = math.random(-200, 200)

			local pos = root.Position + Vector3.new(x,15,z)
			local entitychosen = AvaibleEntities[math.random(1,#AvaibleEntities)]

			SpawnEntity(entitychosen,pos)
		end 
		
	end
end
	

coroutine.wrap(treadmain())()

Additional information:

Help me pls yes

1 Like

Try changing

module.start = function()

To

function module.start()

Nope nothing changed

insertrobloxcharbypasshere

Are you sure the script is a module script too? It looks like a regular server script

A regular server script can still be required and used like a module script, the special thing of a modulescript is that it can be required by the client, you can do this with any script type

Only other think I can suggest is just putting the function in the main script, since it is just one function and not a whole group of them

i did some tweeking and it works

1 Like

you need to make sure the script you’re requiring is a modulescript type and from what i can see from the images you’ve provided, it is not one.