Having problem when string converting to number

Hi Everyone! i am having problem when converting string to number i know that i need to do it with tonumber()
Capture2

Capture1

Change
else if script.Parent.Text >= 1000000 then
to
elseif i >= 1000000 then

2 Likes

Line 8
Fix to :
elseif i >= 1000000 then

1 Like

Ok there are many problems in this script, on the 8th line, you are comparing a number with a string. You aren’t using the variable, you are just using the raw string.

1 Like

Also the logic seems kind of off. If it’s greater than 1000000 then the first block in the if statement will execute and not the second one because you are checking smaller values first.

2 Likes

Can i ask something too? if yes when i am replacing k to 1000 it is saying problem with string “K” how i can do it please?

You’re doing function call syntax. i/k"K" is a function call. What tou want is the concat operator ... i/k .. "K" should work.

Also as someone mentioned, flip your thousands and millions condition. Your millions condition won’t ever run because you already check if it’s more than a thousand before you check that it’s more than a million.

1 Like

it is saying again problem when i am writing …i/k…

Could you show the errors instead of just saying there was an error? But I think I might’ve formatted my post weird. What I meant to say is you that the concat operator is .., and your code should look like i/k .. "K".