Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help?? My Gamepass/Badge cash giving keeps breaking.

Asked by 6 years ago

I've put it into the script where the cash is created too like someone suggested a while back, but it keeps working and not working (mostly not working) and i'm confused on why this is.

Can someone help?

I have multiple badges/gamepasses that I need this for and I also don't know how to put it all in one single function could someone help out with that too?

Gamepass/Badge script

game.Players.PlayerAdded:connect(function(plr)
    local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,540679791) then
        print(plr.Name .. " owns the VIP")
        if cashmoney then
    wait(1)
            cashmoney.Value = cashmoney.Value + 10000
        end
    else
        print(plr.Name .. " doesn't own VIP")
    end
end)

Thanks for your time

-Species

0
Is this in a local script, or a server script, if so what service does it reside in? movsb 242 — 6y

1 answer

Log in to vote
0
Answered by
arshad145 392 Moderation Voter
6 years ago
Edited 6 years ago

Hello,

I made an assumption that the player owns the gamepass. Image of game explorer : Game Explorer I also assumed that "PlayerMoney" is a folder, in which resides a NumberValue which name is = plr.Name.

game.Players.PlayerAdded:connect(function(plr)
    local Asset = game:GetService("MarketplaceService"):GetProductInfo('ID_HERE') --Put ID
    local cashmoney = game.ServerStorage.PlayerMoney:findFirstChild(plr.Name)

    print(Asset.Name .. " has been sold : " .. Asset.Sales.." times.")
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,'ID_HERE') then
        print(plr.Name .. " owns the VIP")
        if cashmoney ~= nil then 
            wait(1) 
            print(cashmoney.Name,cashmoney.Parent,plr.Name,cashmoney.Value)
            cashmoney.Value = cashmoney.Value + 10000
        end

    else
        print(plr.Name .. " doesn't own VIP")
    end
end)


I am still learning RbxLua.

Thank you for reading.

0
Does this have anything to do with cash giving for the gamepass/badge? Unkn0wn_Species 20 — 6y
0
Oh okay let me edit it. arshad145 392 — 6y
Ad

Answer this question