so im trying to make a quest system where you have to find x amount of hidden items. i don't want the same item to be collectable more than once so i tried adding it into a table and checking if its collected. currently it prints both "Already claimed" and "Succesfully claimed" a ton of times and doesnt work.
local ReplicatedStorage = game.ReplicatedStorage
local event = ReplicatedStorage.QuestGiver
bricks = game.Workspace.Bricks
claimedstones = {}
event.OnServerEvent:Connect(function(plr)
for i,brick in pairs(bricks:GetChildren()) do
for i,detector in pairs(brick:GetChildren()) do
detector.MouseClick:Connect(function()
if #claimedstones == 0 then
table.insert(claimedstones,brick)
end
for i,v in pairs(claimedstones) do
if brick == v then
print("Already claimed")
else
for i,cstone in pairs(claimedstones) do
if cstone ~= brick then
table.insert(claimedstones,brick)
print("Succesfully claimed")
end
end
end
end
end)
end
end
end)
