player = script.Parent.Parent.Parent.Parent.Parent
cost = 500
function checkForColt()
found = false
for i, v in pairs(player.Backpack:GetChildren()) do
if v.Name == "Colt" then
found = true
end
end
for i, v in pairs(player.Charater:GetChildren()) do
if v.Name == "Colt" then
found = true
end
end
if found == true then
return true
else
return false
end
end
script.Parent.MouseButton1Click:connect(function()
leaderstats= player:FindFirstChild("leaderstats")
if leaderstats then
Money = leaderstats:FindFirstChild("Points")
if Money then
hasColt = checkForColt()
if Money.Value >= cost and hasColt == false then
Money.Value = Money.Value - cost
NewGun = game.Lighting.Colt:Clone()
NewGun.Parent = Money.Backpack
end
end
end
end)
My leaderboard stats work fine, it out put's no errors and the colt is correctly labeled. 10+ cookiez to the guy the works it out.

1 comment
Try using two variables instead of just one called found. It can be overwritten by the second do loop which could cause the checking for Colt to not go as planned. Also, I believe you might be using your function checkForColt() wrong by making it a variable. Instead on line 29, just call the function by doing only
checkForColt(). Then on line 30, after "and", check your two new variables.