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

I am trying to make it so if you buy a Dev Product, you get awarded a badge. See anything wrong?

Asked by 4 years ago
Edited 4 years ago

Someone helped me with this before, but I had a hard time changing it. If you do see a problem, please tell me which lines to change. I believe the problem is on lines 13-14. Thanks!

local badgeservice = game:GetService("BadgeService")

local id = 2124574372 --- Put Badge ID here

local MarketplaceService = game:GetService("MarketplaceService")

local players = game:GetService("Players")

local ProductID = 98389501 --- Product ID Here

local function processReceipt(receiptInfo) 

    local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then


    return Enum.ProductPurchaseDecision.NotProcessedYet 

    end


badgeservice:AwardBadge(plr. UserId,id)   

    end

    return Enum.ProductPurchaseDecision.PurchaseGranted

end

---e 

MarketplaceService.ProcessReceipt = processReceipt

2 answers

Log in to vote
1
Answered by 4 years ago

I helped you before, and you didnt remove the excessive end of the previous if statement you put there, next time also include the error and which line errors

0
The problem is, when I remove the previous end statement. The word "plr" in line 22, becomes an error. stickymirro511 61 — 4y
0
plr is never defined and look at my post for more info as there is more errors Benjamin_pro1000 3 — 4y
0
yes because you used the `plr` variable but you never defined that variable but you did define player use player instead or `receiptInfo.PlayerId` which is what i said on discord not `plr.UserId` VerdommeMan 1479 — 4y
0
Another error I was able to find, if you look at the Dev Console it says, "Players:GetUserIdFromName() failed because user doesn't exist". How do you prevent that? stickymirro511 61 — 4y
View all comments (2 more)
0
thats a line from a different script, this one doesnt have that line but you probably used the wrong method cuz i cant even find that one but i did find this one GetUserIdFromNameAsync https://developer.roblox.com/en-us/api-reference/function/Players/GetUserIdFromNameAsync VerdommeMan 1479 — 4y
0
Thanks for the help, but for some reason it still won't award the badge. I don't see any errors, which leaves me wondering why it won't award the badge. stickymirro511 61 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

The Dev Wiki says the arguments for the function AwardBadge is (UserId,badgeId) but you have (Player,UserId,badgeId) try doing > badgeservice:AwardBadge(PlayerId,id)

0
wrong he/she put a `.` between not a comma VerdommeMan 1479 — 4y
0
sorry its receiptInfo.PlayerId Benjamin_pro1000 3 — 4y

Answer this question