-
What do I want to achieve?
I want to create a bot that can play spleef minigame. -
What is the issue?
I made a bot that path is made by pathfinding service, but I’m not sure how to make the bot able to predict that the part of a spleef will disappear soon or fix what is causing this issue.
Viedos of issue:
Code of the Bot:
local PathFindingService = game:GetService("PathfindingService")
local CurrentSpleef = game.Workspace.SpleefMinigame.Spleef_3
local NPC = game.Workspace["BOT-1"]
local function GetParts()
local N = {}
for i,v in pairs(CurrentSpleef:GetDescendants()) do
if v:IsA("Part") or v:IsA("BasePart") then
if v.Transparency == 0 then
table.insert(N,#N+1,v)
end
end
end
return N
end
local function DoPath(N,SN)
local path = PathFindingService:CreatePath()
path:ComputeAsync(NPC.HumanoidRootPart.Position,N[SN].Position)
local Waypoints = path:GetWaypoints()
for i,v in pairs(Waypoints) do
local Er = Instance.new("Part")
Er.Parent = workspace
Er.Name = "Er"
Er.Anchored = true
Er.CanCollide = false
Er.Size = Vector3.new(1,1,1)
Er.Position = v.Position
if path.Status == Enum.PathStatus.Success then
if v.Action == Enum.PathWaypointAction.Jump then
NPC.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
NPC.Humanoid:MoveTo(v.Position)
NPC.Humanoid.MoveToFinished:Wait(2)
else
break
end
end
end
while true do
local PartsTable = GetParts()
local SuperNumber = math.random(1,#PartsTable)
DoPath(PartsTable,SuperNumber)
wait()
end
I will be really thankful for help
.