local AttitudeHandler = require(script.AttitudeHandler)
local Needs = require(script.CustomerNeedsHandler)
local PathFindingService = game:GetService("PathfindingService")
local INCREMENT = 0
local MAX = 10
local CUSTOMERDELAY = 1
local CustomerHolder = {}
local CustomerHandler = {}
CustomerHandler.__index = CustomerHandler
function CustomerHandler.new(model,StartPosition:CFrame)
local rotation = CFrame.Angles(0, math.rad(360), 0)
local self = setmetatable({}, CustomerHandler)
self.RIG = model:Clone()
self.RIG.Parent = workspace
self.RIG:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
INCREMENT = INCREMENT + 1
self.RIG.Name = "Customer".. INCREMENT
table.insert(CustomerHolder,self.RIG.Name)
self.RIG:PivotTo(model:GetPivot() * rotation)
self.Atitude = AttitudeHandler.Generate()
self.Need = Needs.Generate()
self.RIG:SetAttribute("Atitude",self.Atitude:GetAttitude())
self.SetNeed = self.RIG:SetAttribute("Wants",self.Need:GetNeed())
return self
end
function CustomerHandler:PathFind(EndPoint)
if INCREMENT > MAX then
table.clear(CustomerHolder)
self.RIG:Destroy()
return
end
local path = PathFindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = false
})
local success, errorMessage = pcall(function()
path:ComputeAsync(self.RIG:WaitForChild("HumanoidRootPart").Position, EndPoint)
end)
if success and path.Status == Enum.PathStatus.Success then
-- For each waypoint, create a part to visualize the path
for _, waypoint in path:GetWaypoints() do
local part = Instance.new("Part")
part.Position = waypoint.Position
part.Size = Vector3.new(0.5, 0.5, 0.5)
part.Color = Color3.new(1, 0, 1)
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
self.RIG:FindFirstChild("Humanoid"):MoveTo(part.Position)
part:Destroy()
end
self.RIG:FindFirstChild("Humanoid").MoveToFinished:Connect(function()
task.wait(CUSTOMERDELAY)
local Model = game.ReplicatedStorage.Customers.Customer
local NewCustomer = CustomerHandler.new(Model)
print("Sup")
local NextCustomerHB = Instance.new("Part",workspace)
--HitBox Stats
NextCustomerHB.CFrame = self.RIG:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,0,3)
NextCustomerHB.Name = "Fornite"
NextCustomerHB.Anchored = true
NextCustomerHB.Size = Vector3.new(7.24, 7.12, 4.33)
NextCustomerHB.BrickColor = BrickColor.new("Crimson")
NextCustomerHB.CanCollide = false
NextCustomerHB.Transparency = 1
NewCustomer:PathFind(NextCustomerHB.Position)
end)
end
end
return CustomerHandler
Line 24 is what changes the primary part cframe but for some reason it doesnt change. (And I didn’t forget to require my module)