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

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

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

1 comment

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.

4 answers

✓ Accepted answer

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.

1 comment

0

Thank you so much! That is like the fifth time i have done that! XD

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.

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