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
-
You should try to use better variable names.
i,p,_a,vare all sort of difficult to understand.configs,positions,parts,part, respectively would be better. -
spawnis 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. -
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.
-
workspace:GetDescendants()is going to loop through every item in workspace. That can get pretty expensive. Consider putting yourConfigurations in a known location instead, so you don’t have to loop through workspace to find them.