So I’m working on a baldi’s basics game on Roblox, because I am bored. and I tried to make the Principal, just wander out as a basic test, and he gets stuck on the yellow doors, The reason what confuses me is that
- The doors and the principal are in collision groups which ignore each other.
- The door contains a pathfinding modifier with Passthrough enabled.
This happens
Streamable
Code snippet
local floorrayc = RaycastParams.new()
floorrayc.FilterType = Enum.RaycastFilterType.Whitelist
floorrayc.FilterDescendantsInstances = {workspace.World.FloorObjects}
function followPath(destination)
--task.spawn(function()
-- for t,y in pairs(script.Parent.Principal.Frames.Slap:GetChildren()) do
-- script.Parent.Principal.fingle.Texture = script.Parent.Principal.Frames.Slap[tostring(t)].Texture
-- task.wait(0.02)
-- end
--end)
--local partt = Instance.new("Part")
--partt.Parent = workspace
--partt.Size = Vector3.new(4,35,4)
--partt.Anchored = true
--partt.Position = destination
--partt.CanCollide = false
--game.Debris:AddItem(partt,1.1)
--print("hi")
--print("test")
local nextWaypointIndex = 0
-- Compute the path
local YAxis = 326.775
local rayca = workspace:Raycast(destination,Vector3.new(0,-100,0),floorrayc)
if rayca ~= nil then
YAxis = rayca.Instance.Position.Y
end
local pos = Vector3.new(destination.X, YAxis,destination.Z)
local success, errorMessage = pcall(function()
path:ComputeAsync(Vector3.new(character.Position.X,character.Position.Y, character.Position.Z), Vector3.new(destination.X, YAxis,destination.Z))
end)
--print(path.Status)
if success and path.Status == Enum.PathStatus.Success then
-- Get the path waypoints
--local sound= character.Move:Clone()
--sound.Name = "CopyMove"
--sound.Parent = character
--sound:Play()
--game.Debris:AddItem(sound,2)
waypoints = path:GetWaypoints()
-- Detect when movement to next waypoint is complete
Moving = true
local HowManyPoints = 0
task.spawn(function()
for i,v in pairs(waypoints) do
HowManyPoints = HowManyPoints + 1
end
end)
local HowManyWaypointSpotsToMove = 1
for i,v in pairs(waypoints) do
if Target ~= nil then
if (destination - Target.HumanoidRootPart.Position).Magnitude >= 12 then
Moving = false
break
end
end
if nextWaypointIndex <= HowManyWaypointSpotsToMove then
-- Increase waypoint index and move to next waypoint
local dist
if Target ~= nil then
dist =(character.Position - Target.HumanoidRootPart.Position).Magnitude
end
nextWaypointIndex += 1
local GoTo = waypoints[nextWaypointIndex].Position
--if Target ~= nil then
--if dist <= 6 then
-- local raycast = workspace:Raycast(character.Position, CFrame.lookAt(character.Position, Target.HumanoidRootPart.Position).LookVector * 20)
-- if raycast ~= nil then
-- if raycast.Instance:IsDescendantOf(Target) then
-- GoTo = Target.HumanoidRootPart.Position
-- end
-- end
-- end
--end
if GoTo ~= nil then
local yax = 326.775
local rayca2 = workspace:Raycast(pos,Vector3.new(0,-100,0),floorrayc)
if rayca2 ~= nil then
yax = rayca.Instance.Position.Y
end
local pos
if Target ~= nil then
if (Target.HumanoidRootPart.Position - character.Position).Magnitude <= 7 then
pos=Vector3.new(GoTo.X,yax + 2.8,GoTo.Z)
else
pos=Vector3.new(GoTo.X,GoTo.Y + 2.8,GoTo.Z)
end
else
pos=Vector3.new(GoTo.X,GoTo.Y + 2.8,GoTo.Z)
end
game.TweenService:Create(character,TweenInfo.new(0.06,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0),{Position = pos}):Play()
-- // DEBUG STUFF LOL
-- local part = Instance.new("Part")
--part.Parent = script.Parent
--part.Size = Vector3.new(0.5,0.5,0.5)
--part.Anchored = true
--part.CanCollide = false
-- part.Position = waypoints[nextWaypointIndex].Position
-- game.Debris:AddItem(part,2)
local dist = (character.Position - pos).Magnitude
repeat task.wait() dist = (character.Position - pos).Magnitude until dist <= 3
--wait(0.05)
end
end
end
task.spawn(function()
repeat task.wait()
-- print(nextWaypointIndex)
-- print(HowManyWaypointSpotsToMove)
until nextWaypointIndex > HowManyWaypointSpotsToMove - 1
Moving = false
end)
end
end