Does anyone know how I could find empty space near a player?
This is so I can spawn a car near a player but not have the car spawn inside a wall or something like that.
I was thinking raycasts around the player, but I couldn’t figure out how to do that. Of course, if you know a better way, drop that in the comments.
So, if anyone knows how I could achieve this, I’m listening!
Grab the parts inside a region surrounding the player using
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local RegionSize = Vector3.new(10, 10, 10)
local UpdateInterval = 1 / 5
local function CheckPlayerRegions()
local Playing = Players:GetPlayers()
for i, Player in pairs(Playing) do
local Character = Player.Character
if not Character then continue end
local Root = Character:FindFirstChild("HumanoidRootPart")
if not Root then continue end
local Params = OverlapParams.new()
local Parts = Workspace:GetPartBoundsInBox(Root.CFrame, RegionSize, Params)
for i, Part in pairs(Parts) do
if Part.Locked and Part.Anchored then -- just an example of parts you *might* want to filter for
print(Player, " : ", Part)
while true do
Got the system working, but how could I use this to tell where there is empty space?