Basically I have this script
script.Parent.MouseButton1Down:Connect(function()
if Contracted.Value == false then
Contracted.Value = false
for i,v2 in pairs(game.Workspace.Contracts:GetChildren()) do
if v2:IsA("Folder") then
if v2.ID.Value == script.Parent.Parent.ID.Value then
game.Workspace.Contracts.ContractCount.Value = game.Workspace.Contracts.ContractCount.Value - 1
jName.Value = script.Parent.Parent.CargoType.Text.Text
jDestination.Value = script.Parent.Parent.Dropoff.EndPoint.Text.Text
jPay.Value = script.Parent.Parent.Pay.Total.Text.Text
p.PlayerGui.Hud.ContractMenu.ContractList.ScrollingFrame.ContractPage.Visible = false
p.PlayerGui.Hud.ContractMenu:TweenPosition(UDim2.new(0.0, 0,1.2, 0), "Out", "Quad", .1, true)
wait(.1)
p.PlayerGui.Hud.ContractMenu.Visible = false
game.Players.LocalPlayer.PlayerGui.Hud.Contracts.OpenClose.Debounce.Value = false
local clone = game.ReplicatedStorage[jName.Value]:Clone()
clone.Parent = game.Workspace.Trailers
local tl = {}
repeat
tl = findRandomChild(game.Workspace.Destinations[script.Parent.Parent.Dropoff.EndPoint.Text.Text].TrailerLocations)
until tl.Taken.Value == false
if tl.Taken.Value == false then
tl.Taken.Value = true
clone:MoveTo(Vector3.new(tl.Position.X,tl.Position.Y + 2,tl.Position.Z))
Basically what happens is if you click the GUI, it will close the gui out, clone a model, and position it at a certain brick. With the idea of my game, I have to have multiple places that the brick can go, so I have a 'Folder' with the possible locations the brick can go to, and a BoolValue inside of those to see if the spot is 'Taken' or not. The script works great, but my only issue is with the Repeat. Once the locations are full, and it can no longer go anywhere else, the game just freezes, because its waiting for taken to become false, which won't happen.
I have a few ideas to solve this, but not sure how to go about it. One idea is to have a loop check to see if all the BoolValue's are true, and if so prevent script from running. Is there a way I can do this? Are there any other ways I could check the values, and if all are set to true (no more spots left) then end the script?

5 comments
This would work if there weren't outside values affecting the taken position.
Basically I have a GUI menu that generates random cargo delivery contracts. When you select a contract it will spawn your cargo at one of the multiple "Spawn locations". Once the player is there and removes his cargo, it will change the Taken value back to false, to allow another cargo to spawn there.
Yes this will work with that, all it's doing is checking the Taken values.
It's been a month, but I learned a lot more and finally came back to this problem and your solution worked great. Thanks man.!
No problem, glad it worked out!