This script below is the original script. When clicked and you have enough money in the leaderboard, it takes a tool from ServerStorage and copies it to the player's inventory. The script is grouped with values "Item", "Price", "Currency", as well as a ClickDetector.
It works completely fine as an item shop. Below is the unchanged item shop script. When I tried modifying it further on my own, it didn't work.
local Item = script.Parent.Item
local Price = script.Parent.Price
local Currency = script.Parent.Currency
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local CurrencyName = player.leaderstats:FindFirstChild(Currency.Value)
local ItemName = game.ServerStorage:FindFirstChild(Item.Value)
if CurrencyName.Value >=Price.Value then
CurrencyName.Value = CurrencyName.Value - Price.Value
ItemName:Clone().Parent = player.StarterGear
ItemName:Clone().Parent = player.Backpack
end
end)
What I need help with is how to edit it so it gives you a badge (not a gamepass) instead of an item if you buy it. I'm not familiar with how BadgeService works, so I was hoping someone here could help me finish the script.
From what I can tell, the value "Item" would no longer necessary and a BadgeID value would need to be added into the group.
After "if CurrencyName.Value >=Price.Value then" would be where the script would give the badge, but I don't know how to phrase that to get it to work.
Any help is appreciated!
