New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

UserId is not a valid member of Workspace?

Asked by 3 months ago

I made a developer product code. The GUI screen works good but not the buying system. The Roblox buying screen did show up but not my leaderboard stats> Here's the code

Marketplaceservice.ProcessReceipt = function(receiptinfo)
    for i, Player in ipairs(game:GetChildren()) do 
        if Player.UserId == receiptinfo.PlayerId then
            if receiptinfo.ProductId == devid then
                Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value + 1000
            end
        end

    end
end

In the output, it said UserId is not a valid member of Workspace also it's clearly seen here that UserId is a member of Player, as shown on Roblox Dev Page: https://developer.roblox.com/api-reference/property/Player/UserId Can anyone fix this? Thanks! P/S: I have FE enabled

1 answer

Log in to vote
0
Answered by 3 months ago

This one works for me, let's see if it works for you.

local Marketplaceservice = game:GetService('MarketplaceService')
local devid = 85192395

Marketplaceservice.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == devid then
                player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000
            end
        end
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end
0
It worked thanks! MinuhaYT 14 — 3mo
Ad

Answer this question