I need the script to find a random free place where my dummy can be teleported in cycle, and for it to work through walls that is teleport into confined spaces. And… is it possible to make pathfinding work according to the same scheme?
2 Likes
i did it with that script
local pp=script.Parent
local params=OverlapParams.new()
params.FilterDescendantsInstances={pp}
params.FilterType=Enum.RaycastFilterType.Blacklist
params.MaxParts=1
local castparams=RaycastParams.new()
castparams.FilterDescendantsInstances={pp}
castparams.FilterType=Enum.RaycastFilterType.Blacklist
function findplace()
local center=workspace.Baseplate.Position
local y=-5
local radius=40
local partsFound={}
local r1,r2
repeat task.wait()
r1=math.random(-radius,radius)
r2=math.random(-radius,radius)
local partsFound=workspace:GetPartBoundsInBox(CFrame.new(r1,y,r2),pp.PrimaryPart.Size,params)
local result=workspace:Raycast(Vector3.new(r1,y,r2),Vector3.new(0,-90,0),castparams)
until not partsFound[1]and result
pp:PivotTo(CFrame.new(r1,y,r2))
end
while task.wait(1) do
findplace()
end
2 Likes