I Been Trying To Make A 2x Cherry Gamepass for my game here is my leaderstats script if somebody could help me make a cherry gamepass it would be highly appreciated
local mps = game:GetService("MarketplaceService")
local DataStore = game:GetService("DataStoreService")
local PlayerData = DataStore:GetDataStore("SupsBoy")
local function LoadData(plr,Cherry,Coins,ItemEquipped,HatEquipped)
local Data = PlayerData:GetAsync(plr.UserId)
if Data then
Cherry.Value = Data.Stats.Cherry
Coins.Value = Data.Stats.Coins
ItemEquipped.Value = tostring(Data.Stats.Item)
HatEquipped.Value = tostring(Data.Stats.Hat)
for _,ItemStored in pairs(Data.Items)do
if not plr.Items:FindFirstChild(ItemStored) then
local Item = Instance.new("BoolValue")
Item.Name = ItemStored
Item.Parent = plr.Items
end
end
end
local Item = game.ServerStorage.Items:WaitForChild(ItemEquipped.Value)
Item:Clone().Parent = plr.Backpack
Item:Clone().Parent = plr.StarterGear
end
local function SaveData(plr)
local Data = {
Stats = {
Cherry = plr.leaderstats.Cherry.Value ;
Coins = plr.leaderstats.Coins.Value ;
Item = plr.ItemEquipped.Value ;
Hat = plr.HatEquipped.Value ;
};
Items = {};
Hats = {};
Pets = {};
}
for _,Item in pairs(plr.Items:GetChildren())do
table.insert(Data.Items,Item.Name)
end
PlayerData:SetAsync(plr.UserId,Data)
end
local function LoadHat(plr,char)
for _,PlayerHat in pairs(char:GetChildren())do
if PlayerHat:IsA("Accessory") and PlayerHat:FindFirstChild("Configure") then
PlayerHat:Destroy()
end
end
if game.ServerStorage.Hats:FindFirstChild(plr.HatEquipped.Value) then
local Hat = game.ServerStorage.Hats:FindFirstChild(plr.HatEquipped.Value)
Hat:Clone().Parent = char
end
end
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local Cherry = Instance.new("NumberValue")
Cherry.Name = "Cherry"
Cherry.Value = 0
Cherry.Parent = leaderstats
local Coins = Instance.new("NumberValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
local Items = Instance.new("Folder")
Items.Name = "Items"
Items.Parent = plr
local StarterItem = Instance.new("BoolValue")
StarterItem.Name = "Bronze Play Button"
StarterItem.Parent = Items
local Cooldown = Instance.new("BoolValue")
Cooldown.Name = "Cooldown"
Cooldown.Value = false
Cooldown.Parent = plr
local ItemEquipped = Instance.new("StringValue")
ItemEquipped.Name = "ItemEquipped"
ItemEquipped.Value = "Bronze Play Button"
ItemEquipped.Parent = plr
local HatEquipped = Instance.new("StringValue")
HatEquipped.Name = "HatEquipped"
HatEquipped.Value = "None"
HatEquipped.Parent = plr
LoadData(plr,Cherry,Coins,ItemEquipped,HatEquipped)
plr.CharacterAdded:Connect(function(char)
LoadHat(plr,char)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
SaveData(plr)
end)
game.ReplicatedStorage.RemoteEvents.Give.OnServerEvent:Connect(function(plr,tool)
local char = plr.Character or plr.CharacterAdded:Wait()
if plr.Cooldown.Value == false then
plr.Cooldown.Value = true
local SubcriberBoost = 0
local CoinsBoost = 01
local CoinMultiplier = 1
local SubMultiplier = 1
if mps:UserOwnsGamePassAsync(plr.UserId,9878002) then SubMultiplier = 2 end
if mps:UserOwnsGamePassAsync(plr.UserId,9878002) then CoinMultiplier = 2 end
for _,PlayerHat in pairs(char:GetChildren())do
if PlayerHat:IsA("Accessory") and PlayerHat:FindFirstChild("Configure") then
local Configure = PlayerHat:FindFirstChild("Configure")
SubcriberBoost = Configure.Cherry.Value
CoinsBoost = Configure.Coins.Value
end
end
plr.leaderstats.Cherry.Value = plr.leaderstats.Cherry.Value + tool.Configure.Cherry.Value + SubcriberBoost * SubMultiplier
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + tool.Configure.Coins.Value + CoinsBoost * CoinMultiplier
game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Cherry",tool.Configure.Cherry.Value + SubcriberBoost * SubMultiplier)
wait(1)
plr.Cooldown.Value = false
end
end)
game.ReplicatedStorage.RemoteEvents.Buy.OnServerEvent:Connect(function(plr,tool)
if tool:FindFirstChild("Configure") then
local Configure = tool:FindFirstChild("Configure")
if not plr.Items:FindFirstChild(Configure.Item.Value) then
if plr.leaderstats.Coins.Value >= Configure.Price.Value then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - Configure.Price.Value
local Item = Instance.new("BoolValue")
Item.Name = Configure.Item.Value
Item.Parent = plr.Items
game.ReplicatedStorage.RemoteEvents.Buy:FireClient(plr,Configure.Item.Value)
end
end
end
end)
game.ReplicatedStorage.RemoteEvents.EquipItem.OnServerEvent:Connect(function(plr,Item)
if Item:FindFirstChild("Configure") then
local Configure = Item:FindFirstChild("Configure")
if plr.Items:FindFirstChild(Configure.Item.Value) then
if plr.Backpack:FindFirstChild(plr.ItemEquipped.Value) then
plr.Backpack:FindFirstChild(plr.ItemEquipped.Value):Destroy()
end
if plr.StarterGear:FindFirstChild(plr.ItemEquipped.Value) then
plr.StarterGear:FindFirstChild(plr.ItemEquipped.Value):Destroy()
end
local Item = game.ServerStorage.Items:FindFirstChild(Configure.Item.Value)
Item:Clone().Parent = plr.Backpack
Item:Clone().Parent = plr.StarterGear
plr.ItemEquipped.Value = Configure.Item.Value
end
end
end)
game.ReplicatedStorage.RemoteEvents.EquipHat.OnServerEvent:Connect(function(plr,Hat)
local char = plr.Character or plr.CharacterAdded:Wait()
local Configure = Hat:FindFirstChild("Configure")
for _,PlayerHat in pairs(char:GetChildren())do
if PlayerHat:IsA("Accessory") and PlayerHat:FindFirstChild("Configure") then
PlayerHat:Destroy()
end
end
local Hat = game.ServerStorage.Hats:FindFirstChild(Configure.Item.Value)
Hat:Clone().Parent = char
plr.HatEquipped.Value = Configure.Item.Value
end)
mps.ProcessReceipt = function(Info)
local plr = game.Players:GetPlayerByUserId(Info.PlayerId)
if Info.ProductId == 996159740 then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1000
game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",1000)
elseif Info.ProductId == 996160053 then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 10000
game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",10000)
elseif Info.ProductId == 996160540 then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 100000
game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",100000)
elseif Info.ProductId == 996161271 then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1000000
game.ReplicatedStorage.RemoteEvents.PopUp:FireClient(plr,"Coins",1000000)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
