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

attempt to perform arithmetic on field 'SellingValue' (a userdata value)?

Asked by 9 years ago

what does "attempt to perform arithmetic on field 'SellingValue' (a userdata value)" mean? I have it so that the value of something is the value NumberValue - SellingValue

here is my script

money = script.Parent.Parent.Money

function onTouched(hit)
    if hit.Name == "TycoonBrick" then
    hit:remove()
    money.Value = money.Value + 25
    elseif hit.Name == "UpgradedTycoonBrick" then
    hit:remove()
    money.Value = money.Value + script.Parent.Parent.Parent.SellingValue
    end
end

script.Parent.Touched:connect(onTouched)

Thanks

0
yogipanda, ehm the thing because it is happening due to a error in scripting if the 'SellingValue' is a specific value then add mostly value or SellingValue.Value and it may work. Animescapetower 10 — 6y

4 answers

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

SellingValue is a NumberValue Object.

You can't add ROBLOX objects.

You meant to add script.Parent.Parent.Parent.SellingValue.Value, which is the Value property, which is a number.



Breaking apart the error:

attempt to perform arithmetic

It's referring to trying to use + (a form of arithmetic)

on field 'SellingValue'

the problem is trying to use SellingValue in +...

(a userdata value)

because it is a userdata, not a number. ROBLOX objects are all called "userdata" by Lua. Since you were expecting these things to be numbers, this is a redflag that you picked the wrong thing.

0
Thank you so much! That is like the fifth time i have done that! XD yogipanda123 120 — 9y
Ad
Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago
script.Parent.Parent.Parent.SellingValue

is an object, not a number, and you can't add to an object. You need to get its Value, which will contain a number.

script.Parent.Parent.Parent.SellingValue.Value
Log in to vote
0
Answered by 9 years ago

Is SellingValue an instance? If so, on line 9 do money.Value = money.Value + script.Parent.Parent.Parent.SellingValue.Value

Log in to vote
0
Answered by 6 years ago

yogipanda, ehm the thing because it is happening due to a error in scripting if the 'SellingValue' is a specific value then add mostly value or SellingValue.Value and it may work.

Answer this question