I am creating a cashier system for my game. Currently it lists all the items the player purchases on a frame. Although if said person checks-out twice it will duplicate the tools onto the list.
I am unsure how to delete the existing list to prevent it from duplicating. This is my current script I am using.
game.ReplicatedStorage.priceCount.OnServerEvent:Connect(function(playerSentFrom, PlayerName)
local playertoCheck = game.Players:FindFirstChild(PlayerName)
local uiGridLayout = script.Parent
--here it finds the tool
if playertoCheck.Character then
for i,v in pairs(playertoCheck.Backpack:GetChildren()) do
if v:IsA("Tool") and v:FindFirstChild("Price") then
local price = v.Name
local tl = Instance.new("TextLabel")
tl.Text = price
tl.Font = "TitilliumWeb"
tl.Parent = script.Parent
tl.Name = price
tl.Size = UDim2.new(1, 0, 0.05, 0)
tl.Parent = uiGridLayout.Parent
tl.TextScaled = true
tl.TextColor3 = Color3.fromRGB(255, 255, 255)
tl.BackgroundTransparency = 1
wait(0.5)
end
end
end
end)
Has anyone got any ideas on how to remove the list?