Script Error ( Expected ‘until’ (to close ‘repeat’ at line 75), got ‘end’ )

Hello there! This is my second time posting this because on the first one I had a solution but later it didn’t work. I have an error on my script when I edited the script exhausted line and now I can’t figure out what’s going on with the script so here’s the script

local Cooldown = 4
local MaxPerZone = 20

local Zones = {}
local Coins = {}

local coinsSetTable = {}
local Spawners = {}

for i,v in pairs(workspace.Coins:GetChildren()) do
	Zones[v] = 0
	local ZoneModule = require(game.ReplicatedStorage.Zone)
	local Zone = ZoneModule.new(v)
	
	local spawnersTable = {}
	for i, spawner in pairs(v:GetChildren()) do
		if not spawner:FindFirstChild("Coin")then
			spawnersTable[v] = nil
		else
			spawnersTable[v] = "Coin"
		end
	end
	Spawners[v] = spawnersTable
	
	-- Coins Part
	local CoinsWorld = {}
	
	for _,Coin in pairs(game.ReplicatedStorage.Coins:FindFirstChild(v.Name):GetChildren()) do
		if not Coin:IsA("Script") and not Coin:IsA("Folder") then
			table.insert(CoinsWorld,Coin)
		end
	end
		
	Coins[v] = CoinsWorld
	
	
	-- If Player in zone
	
	Zone.playerEntered:Connect(function(player)
		Zones[v] += 1

	end)
	
	Zone.playerExited:Connect(function(player)
		Zones[v] -= 1

	end)
	
	
end


function getRandomInPart(part)
	local random = Random.new()
	local randomCFrame = part.CFrame * CFrame.new(random:NextNumber(-part.Size.X/2,part.Size.X/2), 0, random:NextNumber(-part.Size.Z/2,part.Size.Z/2))
	randomCFrame = CFrame.new(randomCFrame.X,2,randomCFrame.Z)
	return randomCFrame
end


while wait(Cooldown) do
	
	for i,v in pairs(workspace.Coins:GetChildren()) do
		local spawnersTable = {}
		for j, spawner in pairs(v:GetChildren()) do
			table.insert(spawnersTable,spawner)
		end
		Spawners[v] = spawnersTable
	end
	
	for i,v in pairs(workspace.Coins:GetChildren()) do
		if Zones[v] > 0 then --and #v:GetChildren() <= MaxPerZone then
			local Spawner
			local SpawnerNumber
			repeat 
				SpawnerNumber = math.random(1,#Spawners[v])
				Spawner = Spawners[v][SpawnerNumber]
--			until not Spawner:FindFirstChild("Coin")
			
			
			local CoinsRandomsNumber = math.random(1,#Coins[v])
			local NewCoins = Coins[v][CoinsRandomsNumber]:Clone()
			NewCoins.CanCollide = true
			NewCoins.Name = "Coin"
			NewCoins.CFrame = getRandomInPart(v)
			NewCoins.CFrame = Spawner.CFrame
			NewCoins.Parent = Spawner
			Spawner = "Coin"
			NewCoins.Anchored = true
		end
	end
	
	
	
	
end

That’s the error btw

And this is the line that I edited (Disabled it with( --) because it freezes the game)

1 Like

all repeat until loops need a task.wait() somewhere in them, uncomment the until line and add task.wait() behind it

You need an until to use the repeat keyword.

You’ve commented that line with a -- so the script ignores it.

Add another until or remove the --

1 Like

First, that doesn’t answer OP’s question. Secondly, you claim about needing a wait is wrong.

local x = 0
repeat x += 1 until x > 10

print("It worked!")

This will run fine.

OP simply commented out the line that closed the repeat loop.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.