Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --they MUST have something allocated to them
- getgenv().settings = {
- ['AutoRestock'] = {
- ['Enabled'] = true,
- ['Delay'] = 5, -- seconds
- }
- }
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Sellables = ReplicatedStorage.Sellables
- local Remotes = ReplicatedStorage.Remotes
- local BuyStorage = Remotes.BuyStorage
- local StockShelfFunction = Remotes.StockShelfFunction
- local function getPlot()
- for index, value in next, getgc(true) do
- if type(value) == "table" and rawget(value, "Plot") then
- return value.Plot
- end
- end
- end
- local Plot = getPlot()
- local function TypeToBuy(Item)
- for index, value in next, Sellables:GetChildren() do
- if value:FindFirstChild(Item,true) then
- return value.Name
- end
- end
- end
- local function BuyAllItems()
- for Index, Value in next, Plot.Objects:GetChildren() do
- for Index, Value in next, Value:GetChildren() do
- if Value:FindFirstChild("Sellables") then
- local AmountToBuy = #Value.Sellables.Items:GetChildren() - Value.SellableAmount.Value
- if AmountToBuy > 0 then
- BuyStorage:InvokeServer(TypeToBuy(Value.Sellable.Value),AmountToBuy,true)
- wait(.1)
- StockShelfFunction:InvokeServer(Value, Value.Sellable.Value)
- end
- end
- end
- end
- end
- while settings['AutoRestock'].Enabled do
- BuyAllItems()
- wait(settings['AutoRestock'].Delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement