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!
Try "IntValue" instead of "NumberValue". Line 13 you added "1", which is an int value. Try that or try adding 1.0 instead.
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: Part
s, Value
s, Model
s, Decal
s, ParticleEmitter
s, 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 Instance
s have properties that you can perform arithmetic on, you cannot perform arithmetic on the Instance
s 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