Hello everyone, I want to make a order button system that you need to click in the great order. But when the player is clicking button in order, that restart the process. But each time the repeat wait starts again, the processes are superimposed because in the output, we observe double prints if we are wrong once, then three times when we are wrong 3 times…
Help me
Here is the loop part of the script :
repeat wait()
local VerrouOrder = {}
for i = 1, (#Group.Verrous:GetChildren() / game.ReplicatedStorage.PipeGazLeakValues.VerrousDivid.Value) do
local PickVerrou = VerrousToPlace[math.random(1, #VerrousToPlace)]
PickVerrou.Color = Color3.fromRGB(255, 0, 0)
PickVerrou.Transparency = 0.7
PickVerrou.Pop:Play()
PickVerrou.ClickDetector.MaxActivationDistance = 20
table.insert(VerrouOrder, PickVerrou)
table.remove(VerrousToPlace, table.find(VerrousToPlace, PickVerrou))
wait(0.3)
end
local Step = 1
local IsFalse = false
for i, TheVerrou in pairs(VerrouOrder) do
TheVerrou.ClickDetector.MouseClick:Connect(function()
print(table.find(VerrouOrder, TheVerrou), Step)
if table.find(VerrouOrder, TheVerrou) == Step then
TheVerrou.Pop:Play()
TheVerrou.ClickDetector.MaxActivationDistance = 0
TheVerrou.Transparency = 0
TheVerrou.Color = Color3.fromRGB(0, 0, 0)
Step += 1
VerrouPlaced += 1
else
if IsFalse == false then
IsFalse = true
for i, BVerrou in pairs(VerrouOrder) do
table.insert(VerrousToPlace, BVerrou)
BVerrou.Transparency = 1
VerrouPlaced -= 1
end
print(VerrousToPlace)
Step = 5
end
end
end)
end
repeat wait() until Step == 5
wait(1)
until VerrouPlaced >= #Group.Verrous:GetChildren()