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

Is this a problem with the location of my script, or the script itself?

Asked by 7 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

This is currently in the ServerScriptService, and the Gui is in the StarterGui. Any thoughts?

game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService("MarketplaceService")

function getPlayerFromId(id)
    for i,v in pairs(game.Players:GetChildren()) do
        if v.userId == id then
            return v
        end
    end
    return nil
end

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local productId = receiptInfo.ProductId
    local playerId = receiptInfo.PlayerId
    local player = getPlayerFromId(playerId)
    local productName 

    -- Down below is an example of a Cash boost

    -------------------------------------------------------------------

    if productId == 35803838 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + 5000
            end
        -------------------------------------------------------------------
        -------------------------------------------------------------------

    if productId == 35803911 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + 25000
            end
        -------------------------------------------------------------------
                -------------------------------------------------------------------

    if productId == 35803887 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + 100000
            end
        -------------------------------------------------------------------
        -------------------------------------------------------------------

    if productId == 35803946 then
        local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
            if cashmoney then
                cashmoney.Value = cashmoney.Value + 1000000
            end
        -------------------------------------------------------------------

        -- Down below is an example of a Health boost

        -------------------------------------------------------------------

        elseif productId == 35803808 then
        local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
        local char = player.Character
        char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
        wait()
        char.Humanoid.Health = char.Humanoid.MaxHealth
        -------------------------------------------------------------------

        -- Down below is an example of a WalkSpeed boost

        -------------------------------------------------------------------
        elseif productId == 35803720 then
        local char = player.Character
        if char then
            local human = char:FindFirstChild("Humanoid")
            if human then
                human.WalkSpeed = human.WalkSpeed + 15
            end
        end
        -------------------------------------------------------------------

        -- Down below is an example of a gear giver

        -------------------------------------------------------------------

        elseif productId == 35803755 then
        game.ServerStorage.SentryTurret:Clone().Parent=player.Backpack

          -- Example if you want to make another gear giver, delete the 2 lines if you dont need it

        -------------------------------------------------------------------
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted 
    end

1
What is the problem? areiydenfan00 115 — 7y
0
Cash, speed, and gear is not being given to the players when they purchase the gamepass hurricanedog 0 — 7y
0
"cashmoney" is a local variable. So it's scope is only going to be inside this script. If your leaderboard script is separate from this, than it won't transfer that. That's all I can think of looking at it. areiydenfan00 115 — 7y

Answer this question