I was unsure what to put in the title since I couldn’t pinpoint what the issue is about exactly. I tried to search the errors on the forum but the solutions provided didn’t seem appropriate for my case. I have a script that procedurally generates the map (nodes > paths > rooms)
I would like to note that the issue only happens half of the time. The other half, the entire code runs as intended.
i used the print() function for troubleshooting and the values it outputted seemed normal; -33, 8, -132...south->0, 0, -66 contrary to the error on workspace:GetPartBoundsInRadius(pathInst.Position + (directions[tags[1]] / 2), 8) saying “attempt to perform arithmetic (div) on int and nil” or something like that
What i did after that was try and call the function with pcall to see what it would do, and it outputted “attempt to call a table value” this time
local directions = {
north = Vector3.new(0, 0, branchLength),
south = Vector3.new(0, 0, -branchLength),
east = Vector3.new(-branchLength, 0, 0),
west = Vector3.new(branchLength, 0, 0)
}
local function createRooms()
for _, pathInst in pairs(workspace.Template.Paths:GetChildren()) do
if pathInst.Name ~= "Origin" then
local tags = collectionService:GetTags(pathInst)
if tags then
task.wait(0.01)
local success, result = pcall(workspace:GetPartBoundsInRadius(pathInst.Position + (directions[tags[1]] / 2), 8))
if success then
if #result == 0 then
local newRoom = Instance.new("Part")
newRoom.Anchored = true
newRoom.Parent = workspace.Template.Rooms
newRoom.Position = pathInst.Position + (directions[tags[1]] / 2)
newRoom.Size = Vector3.new(10, 10, 10)
totalParts += 1
collectionService:AddTag(newRoom, opp[tags[1]])
pathInst.Color = Color3.new(0, 1, 0)
else
collectionService:RemoveTag(pathInst, tags[1])
pathInst.Color = Color3.new(1, 0, 0)
end
else
print(result, tostring(pathInst.Position).."..."..tostring(tags[1]).."->"..tostring(directions[tags[1]])) -- i used this for troubleshooting
pathInst.Color = Color3.new(1, 0, 0)
end
else
pathInst.Color = Color3.new(1, 0, 0)
end
end
end
end
i’m particularly confused since the values don’t seem to show anything unusual but it still throws the errors I said.
