#why am I getting an error trying to subtract 2 numbers?

1 messages · Page 1 of 1 (latest)

modest apex
#

coins is a string of 100 so how i make it into a number of 100?

#

this works and im basically doing the exact same thing

modest apex
cunning charm
#

and anyways dont store coins on textlabel

#

use attributes or tables

modest apex
#

im not

cunning charm
#

oh ok

cunning charm
modest apex
#

the textlable is equaling coinsvalue so the coins can be displayed on the gui but im getting this error that once i get resolved will prob fix the problem im having

sleek summit
#

And the event function receives 1

#

Which would be the string

#

Bcuz its the first parameter

modest apex
sleek summit
#

Oh wait nvm mb

#

Holon

modest apex
#

and when i print the coins value in the else part its 100

cunning charm
#

the only solution here is tonumber

sleek summit
#

Why don't you try printing the values outside the if statement

cunning charm
#

or change how the system works

modest apex
cunning charm
modest apex
cunning charm
#

also u really should send the coins’ value as a number

#

not string

sleek summit
modest apex
modest apex
sleek summit
#

Put the prints above the if statement

#

And make them clearer like

#

"START"

#

"CONDITION1"

modest apex
#

mk

sleek summit
#

"CONDITION2"

modest apex
sleek summit
modest apex
#

idk why error is above it but it is

sleek summit
modest apex
sleek summit
#

Like

modest apex
sleek summit
#

Holon coinsvalue = tonumber(coinsvalue) - tonumber(coins)

sleek summit
#

So that means they're both strings

#

Or

#

1 of them is a string that csnt be turned into number

modest apex
#

but its sayd number and string

sleek summit
#

So if that vwhen you turn it into number and it's nil

#

That means it cant be turned to number

modest apex
#

woulddnt it print "nil"?

sleek summit
#

You should define it at top

sleek summit
sleek summit
#

Number and nil

modest apex
#

u right

modest apex
sleek summit
#

Ok could you just send the whole script , this whole thing kinda confusing

modest apex
#

do u want both scripts where it fires the bindable event (im 99.999% sure the problem aint there)

sleek summit
#

Mmm

modest apex
#

u can prob ignore the last 2 (this is the first script)

#

this is prob all u need from the second script

#

ive got sum stuff to change at the top of the first script and the stuff for portals but im doing this first cuz its not working and I dont know why but ik why that wont work up there

steady bluff
#

Try
coins = tonumber(coins)
coinsvalue = tonumber(coinsvalue)
Then u subtract
coinsvalue -= coins