Hey there, So I’m making a gamepass where you get more money if you buy it and my script don’t work
my code:
local gamepass_id = 46359762
local stat = "Cash"
local gamepass_stat = 5000
--End of Settings
game.Players.PlayerAdded:Connect(function(player)
local fold = Instance.new("Folder", player)
fold.Name = "leaderstats"
local val = Instance.new("IntValue", fold)
val.Name = "Cash"
val.Value = 0
local awarded = Instance.new("BoolValue", player)
awarded.Name = "Awarded"
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepass_id) and player.Awarded.Value == false then
player.Awarded.Value = true
val.Value = val.Value + gamepass_stat
end
end)
while wait(3) do
for i,v in pairs(game.Players:GetChildren()) do
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(v.UserId, gamepass_id) and v:WaitForChild("Awarded").Value == false then
v.Awarded.Value = true
v.leaderstats:FindFirstChild(stat).Value = v.leaderstats:FindFirstChild(stat).Value + gamepass_stat
end
end
end