Heya Everyone!!
I’m making an entity system and I’m trying to make it so that it’ll wander around random waypoints. The issue is that the entity refuses to walk towards them. Is there a reason as to why?
(This is the snippet of the module script. Aka, the entity system,)
--//Creating the entity
function BaseEntity:CreateEntity(EntityName)
--//Finding entity
local RequestedEntity = RegularFolder:FindFirstChild(EntityName) if not EntityName then
RequestedEntity = SpecialFolder:FindFirstChild(EntityName) if not EntityName then
warn("CANNOT FIND ENTITY: "..EntityName)
return
end
end
--//Creating entity
local self = setmetatable({}, BaseEntity)
self.Entity = RequestedEntity:Clone()
self.Humanoid = RequestedEntity:FindFirstChildWhichIsA("Humanoid")
self.Entity.Parent = game.Workspace
--//List of entity behaviors & assinging them to their respective entity.
self.EntityBehaviors = {
["Starvlud"] = {
["Behavior"] = function()
self:Wander()
end,
}
}
self.EntityBehaviors.Starvlud.Behavior()
return self
end
--//Default functions
function BaseEntity:Wander()
local Walkpoints = workspace:WaitForChild("Walkpoints"):GetChildren()
local RandomWalkPoint = Walkpoints[math.random(1,#Walkpoints)]
while task.wait() do
local NewPath = PathfindingService:CreatePath()
NewPath:ComputeAsync(self.Entity.PrimaryPart.Position, RandomWalkPoint.Position)
if NewPath.Status == Enum.PathStatus.Success then
local Waypoints = NewPath:GetWaypoints()
for _, Waypoint in pairs(Waypoints) do
self.Humanoid:MoveTo(Waypoint.Position)
self.Humanoid.MoveToFinished:Wait(2)
end
end
end
end