For some reason, after running table.remove and printing the table, it doesn’t seem to actually remove the value. I have tried using table.find after removing, and it gives nil, so it should be removed.
Here’s the script:
game.ReplicatedStorage.events.delete.OnServerEvent:Connect(function(plr, tableToDelete)
local data = HttpService:JSONDecode(save:GetAsync("User-".. plr.UserId))
local merged = {}
if data then
for i, v in data do
table.insert(merged, v)
end
end
for i, v in plr.marshmallowsCollected:GetChildren() do
if not table.find(merged, v) then
table.insert(merged, v)
end
end
print(merged)
for i, v in tableToDelete do
if table.find(merged, v) then
table.remove(merged, table.find(merged, v))
plr.marshmallowsCollected:FindFirstChild(v):Destroy()
end
end
print(merged)
save:SetAsync("User-" .. plr.UserId, HttpService:JSONEncode(merged))
end)