Hi im looking to know how i’d make a script that increases the OrderNumber value by 1 everytime the event.checkout occurs. I have two different cash registers and when they print receipts they have order numbers but both start from 0. Preferably i would like it if cashier1 has taken 5 orders then cashier2 will start from 5 for example.
I think id need to make a bindable event which would transfer the number everytime checkout is pressed but im not sure?
local ordernumber = 0
Events.Checkout.OnServerEvent:Connect(function (Player, Order)
ordernumber += 1
CustomerScreen.Order.Visible = false
CustomerScreen.Checkout.Visible = true
local Receipt = game.ServerStorage.Receipt:Clone()
Receipt.Timestamp.Value = os.time()
Receipt.Receipt.Receipt.Cashier.Text = "Served by: "..Player.Name
local Game = game
local ServerStorage = Game:GetService("ServerStorage")
local BindableEvent = game.Workspace.Tech.Events.BindableEvent
Receipt.Receipt.Receipt.Number.Text = "Order: "..ordernumber
Receipt.Receipt.Receipt.Order.Text = Order
Receipt.Parent = Player.Backpack
end)
local DataStoreService = game:GetService("DataStoreService") --Get Service
local OrderNumberStore = DataStoreService:GetDataStore("ordernumber") --Get Order Nymber Data Store
Events.Checkout.OnServerEvent:Connect(function (Player, Order)
ordernumber += 1
OrderNumberStore:SetAsync("OrderNumber",ordernumber) --Set order number
CustomerScreen.Order.Visible = false
CustomerScreen.Checkout.Visible = true
local Receipt = game.ServerStorage.Receipt:Clone()
Receipt.Timestamp.Value = os.time()
Receipt.Receipt.Receipt.Cashier.Text = "Served by: "..Player.Name
local Game = game
local ServerStorage = Game:GetService("ServerStorage")
local BindableEvent = game.Workspace.Tech.Events.BindableEvent
Receipt.Receipt.Receipt.Number.Text = "Order: "..OrderNumberStore:GetAsync("OrderNumber") --Use order number in receipt
Receipt.Receipt.Receipt.Order.Text = Order
Receipt.Parent = Player.Backpack
end)