So recently, I have made this script that should connect to my leaderboard that does work but it never buys the item... Could you please see what's wrong and fix it for me?
-- Leaderboard Script --
if type == "Individual" then
if winner and credits then
if winner.Character and winner:FindFirstChild("leaderstats") then
if winner.leaderstats:FindFirstChild("Credits") then
winner.leaderstats.Credits.Value = winner.leaderstats.Credits.Value + credits
end
end
end
-- Shop button script --
player = script.Parent.Parent.Parent.Parent.Parent
Credits = player.leaderstats.KOs -- My leaderboard doesn't use KOs do I change it with credits?
price = 150
tool = game.ServerStorage:findFirstChild("ItemName")
function buy()
if Credits.Value >= price then
Credits.Value = Credits.Value - price
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear
end
end
script.Parent.MouseButton1Down:connect(buy)
