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

Multiply UserData Value with a script value?

Asked by 6 years ago

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)
0
What is "Cash"? If it's a value, you need to reference it's .Value property. Eqicness 255 — 6y

1 answer

Log in to vote
1
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago

"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"

0
Thanks... I didn't actually see I forgot to add ".Value" I was just skimming through the code super fast. YouSNICKER 131 — 6y
Ad

Answer this question