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

Multiply UserData Value with a script value?

Basically I want the player to donate 1% of their cash only... I tried down here but got the error "attempt to perform a arithmetic on field 'Cash' (a userdata value)"

local data = player.PlayerData --this works
local increment = 0.01 --1% of their money
local donationValue = data.Cash * 0.01 --this is the line giving the error by the way
print(donationValue)

1 comment

0

What is "Cash"? If it's a value, you need to reference it's .Value property.

1 answer

✓ Accepted answer

"Cash" is an instance. Your trying to multiply an instance. Arithmetic doesn't work that way. To get the VALUE held BY THE VALUE, it must be "Cash.Value"

1 comment

0

Thanks... I didn't actually see I forgot to add ".Value" I was just skimming through the code super fast.

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