Region3 - Contradicting values?

Oh, also, I don’t think this code will ever run, right? Where are you updating the Character value so that the first line will stop waiting? That line should be something like this:

local Character = game.Players.LocalPlayer.Character
if not Character then
    Character = game.Players.LocalPlayer.CharacterAdded:Wait()
end

Or just don’t have the character check at all. You don’t use it in the loop.

Also in the spirit of code review

  1. You should try to use better variable names. i, p, _a, v are all sort of difficult to understand. configs, positions, parts, part, respectively would be better.

  2. spawn is generally discouraged, especially as you’re using it here (in a loop of indefinite size). I would recommend using a single loop (in a coroutine if needed) for all the regions in order, since there’s no need to run this in parallel.

  3. This seems like its a localscript. Also in the spirit of reducing thread count, I would just have a single loop on the server which assigns regions to players. It helps defend against exploiters as well, since you’re taking control away from the client.

  4. workspace:GetDescendants() is going to loop through every item in workspace. That can get pretty expensive. Consider putting your Configurations in a known location instead, so you don’t have to loop through workspace to find them.

1 Like