Here is my script so far
local ting = 0
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Cash")
cash.Value = cash.Value -100
wait(10)
end
end
ting = 0
end
end
script.Parent.Touched:connect(onTouched)
shirtid = "rbxassetid://"
pantsid = "rbxassetid://"
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid")then
char = hit.Parent
if char:findFirstChild("Shirt") then
char.Shirt.ShirtTemplate = shirtid
else
a = Instance.new("Shirt", char)
a.Name = "Shirt"
a.ShirtTemplate = shirtid
end
if char:findFirstChild("Pants") then
char.Pants.PantsTemplate = pantsid
else
b = Instance.new("Pants", char)
b.Name = "Pants"
b.PantsTemplate = pantsid
end
end
end)
pantsid = "rbxassetid://"
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid")then
char = hit.Parent
if char:findFirstChild("Shirt") then
char.Shirt.ShirtTemplate = shirtid
else
a = Instance.new("Shirt", char)
a.Name = "Shirt"
a.ShirtTemplate = shirtid
end
if char:findFirstChild("Pants") then
char.Pants.PantsTemplate = pantsid
else
b = Instance.new("Pants", char)
b.Name = "Pants"
b.PantsTemplate = pantsid
end
end
end)
But it just gives me the cloths when I have 0 I need it so it does not let them have it if they have enough I also took out the cloths Ids here

2 comments
The error is in buy or in clothing? I did not quite understand.
I want it so that if I dont have enough it wont let me get it the clothing if I dont have enough