I'm trying to make a system where a Room spawns and connected to any available door of previously spawned rooms. It works, except for detecting whether or not the room can fit where it would be connecting. For some reason, when using GetPartBoundsInBox() it detects parts that are next to (beside) the Room but not actually inside. I've tried messing with Tolerance and other ways of checking for "parts in a part" but to no avail.
#Room Spawn System Help
1 messages · Page 1 of 1 (latest)
Can I get the script for detection
sure
local SensorTestFolder = workspace.SensorTesting;
local PhysicalRoomFolder = SS.Rooms;
local Rooms = {};
local Room = {}
function Room.GetRooms() return Rooms; end
function Room.CreateRoom(name : string, _type : string, rarity : string) : {}
local newRoom = {};
newRoom.Name = name;
newRoom.Type = _type;
newRoom.Rarity = rarity;
newRoom.Occupants = {};
newRoom.Ports = {};
Rooms[name] = newRoom;
return newRoom;
end
function Room.KeyExists(key : string) : boolena
return Rooms[key] ~= nil;
end
function Room.GetPorts(key : string) : {BasePart} | false
if Room.KeyExists(key) then return Rooms[key].Ports; end
return false;
end
function Room.GetRarity(key : string) : string | false
if Room.KeyExists(key) then return Rooms[key].Rarity; end
return false;
end
function Room.GetOccupants(key : string) : {Model} | false
if Room.KeyExists(key) then return Rooms[key].Occupants; end
return false;
end
function Room.GetType(key : string) : string | false
if Room.KeyExists(key) then return Rooms[key].Type; end
return false;
end
function Room.GetPhysicalRoom(key : string) : Model | false
if Room.KeyExists(key) then return PhysicalRoomFolder:FindFirstChild(key); end
return false;
end
function Room.GetName(key : string) : string | false
if Room.KeyExists(key) then return key; end
return false;
end
return Room;
``` For starters, this is the module I used to define each room
Here's a runthrough of the main code
Have not read through the script yet but I'm a bit confused
Are you trying to detect the parts inside the room?, or parts outside the room
I'm detecting for parts that would intersect the room if it were placed in that spot by creating a clone and setting its cframe to the proposed area. It won't sense its own parts, or any players who are around the area. If parts are in the area it would be placed I make it choose a different door to spawn from
the clone is never in workspace until the area is proven to be clear to place it