CCCPaste

Work At A Pizza Place: Claim Corn Maze Chests

--[[
    Work At A Pizza Place: Claim Corn Maze Chests
    by darraghd493
]]

repeat task.wait() until game:IsLoaded()

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local StarterGui = game:GetService("StarterGui")

local Network = require(ReplicatedStorage:WaitForChild("LibraryFolder"):WaitForChild("Network"))
local Chests = Workspace:WaitForChild("CornMaze"):WaitForChild("Chests")

local count = 0
for _, chestObj in pairs(Chests:GetChildren()) do
    if chestObj:FindFirstChild("Index") then
        if not chestObj:FindFirstChild("Particle") or not chestObj.Particle:FindFirstChild("Sparkle") or not chestObj.Particle.Sparkle.Enabled then
            continue
        end
        print("Claimed chest:", chestObj.Name, chestObj.Index.Value)
        Network:FireServer("ChestOpened", chestObj.Index.Value)
        count = count + 1
    end
end

StarterGui:SetCore("SendNotification", {
    Title = "Script",
    Text = "Claimed "..count.."/" .. #Chests:GetChildren() .. " corn maze chests.",
    Duration = 5
})