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
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.
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
Is SellingValue an instance? If so, on line 9 do money.Value = money.Value + script.Parent.Parent.Parent.SellingValue.Value
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.