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

What does: attempt to perform arithmetic on local 'farts' (a userdata value) mean?

I am trying to make a fart simulator for a fun challenge. I created a value where the farts will be held but it keeps returning this error: attempt to perform arithmetic on local 'farts' (a userdata value)

The player will equip a tool called fart and click to fart basically


 local fart = script.Parent
 local ready2Fart = true
 
 
 local function onClick()
	local farts = Instance.new("NumberValue")
 	farts.Name = "farts"
 	farts.Parent = script.Parent
 	
 	if ready2Fart == true then
 		ready2Fart = false
 		print("FAAARRRT")
 		farts = farts + 1
 		wait(0.7)
 		ready2Fart = true
 	end
 end
 
 fart.Activated:connect(onClick)


any help will be appreciated.

Thanks!

1 comment

0

wow, what a game, lol

3 answers

Try "IntValue" instead of "NumberValue". Line 13 you added "1", which is an int value. Try that or try adding 1.0 instead.

1 comment

0

That's not the issue.

You were trying to add to the NumberValue object itself, not its Value property.

farts = farts + 1

should be

farts.Value = farts.Value + 1

About the error

The words "attempt to perform arithmetic" mean you tried to apply a mathematical operation (subtract, multiply, divide, or in this case, add) to something.

Then, it says something about userdata. A "userdata value" in Roblox means an "Instance". For example: Parts, Values, Models, Decals, ParticleEmitters, or really anything else you can Insert into the Workspace. More specifically, "local 'farts' (a userdata value)" means that the error is specific to an Instance assigned to the variable farts.

While some Instances have properties that you can perform arithmetic on, you cannot perform arithmetic on the Instances themselves. This is what caused your error.

u see, a fart is a gas

and a user is a user

a user data is data from the user

gas comes out of the user

this means that there is a major error in your:

ASS

Thus bringing me to how you can fix it:

The way you coded it makes farts look like an object.. now of course, we know.. that if a fart solidifies then its a poop.

so the solution is to look deep INTO the poop and find the fart bubbles. THUS....

farts.Value = farts.Value + 1

Thank you for coming to my ted talk and always be ready2fart = true

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