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

Developer Products Problem?

Asked by
crut24 50
8 years ago

I am trying to make a Donation Tab that calculates all the Tix and Robux donated to me. When i try to print the CurrencyType it gives me an error:

MarketplaceService.ProcessReceipt = function(receiptInfo)
    print(receiptInfo.PlayerId .. " just bought " .. receiptInfo.ProductId.. " for ".. receiptInfo.CurrencySpent .." ".. receiptInfo.CurrencyType)
end)

Error: Workspace.DonationTab.MainParts.Script:2: attempt to concatenate field "CurrencyType" (a userdata value)

I dont know how to fix this. If you know how to solve the problem plz tell me.

0
You gave us the wrong script. The error says their is a 17th line which you have not provided. Give us the correct script (Full script) so we may assist you. alphawolvess 1784 — 8y
0
I dont want to add the whole script. Thats the basic idea. When i try to print the receiptInfo.CurrencyType this error appears crut24 50 — 8y
0
You must add the rest of the script. We can't just fix the print. We won't steal it - why would someone steal something he most probably doesn't even know what it is anyway? Marios2 360 — 8y
0
CurrencyType is a userdata value which can be compared to a Enum, just put .Name after CurrencyType. Since Name is a valid member of a Enum for the CurrencyType. M39a9am3R 3210 — 8y

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
8 years ago

As you have major paranoia, i'll just fix your very tiny segment. If you want to insert something that isn't a string in a string, you must use tostring to insert it. Most stuff will work, except for some exceptions.

MarketplaceService.ProcessReceipt = function(receiptInfo)
    print(tostring(receiptInfo.PlayerId) .. " just bought " .. tostring(receiptInfo.ProductId).. " for ".. tostring(receiptInfo.CurrencySpent) .." ".. recieptInfo.CurrencySpent.Name)
end)

Similarly you can use tonumber to make a string into a number or an integer, but only if it is like "5" and you want that string to be used as a number then.

0
Let me try it out if it works you have the Answer crut24 50 — 8y
0
Wait, i updated it not to print out the CurrencyType as an Enum. You can do what i did before or update it to what i did now. Marios2 360 — 8y
0
Now how do i check if the CurrencyType is in Robux or Tix? crut24 50 — 8y
0
I just did that. A wee birdie called M39a9am3R told me if you put a .Name after an Enum property you can get the value as a string. I used that inside the script so it prints the currency itself. If this solves your problem don't forget to accept the answer! Marios2 360 — 8y
View all comments (2 more)
0
I didnt really understand what you mean by that crut24 50 — 8y
0
I did it by my self. Thanks for your help crut24 50 — 8y
Ad

Answer this question