
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
