Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Developer Products Problem?

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.

4 comments

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.

0

I dont want to add the whole script. Thats the basic idea. When i try to print the receiptInfo.CurrencyType this error appears

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?

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.

1 answer

✓ Accepted answer

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.

6 comments

0

Let me try it out if it works you have the Answer

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.

0

Now how do i check if the CurrencyType is in Robux or Tix?

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!

0

I didnt really understand what you mean by that

0

I did it by my self. Thanks for your help

This discussion is preserved as it was. New answers, comments, and votes are closed.