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

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

Asked by 6 years ago
Edited 6 years ago

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!

0
wow, what a game, lol FlippinAwesomeCrew 62 — 6y

3 answers

Log in to vote
0
Answered by
vebel 2
6 years ago

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

0
That's not the issue. User#20476 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Log in to vote
0
Answered by 3 years ago

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

Answer this question