Int value not adding?

I’m completely unsure why this script doesn’t work. I’ve looked up multople posts with this exact same issue and the issues and solutions are nearly identical?

local count = char.Count.Value

while wait(1) do
	count = count + 1
	print(char.Count.Value)
end

I’ve made sure “count” is indeed an int value. Is this because the int value is inside the character? I’ve recreated this exact script with a different int value and it seems to work. I’m stumped.

1 Like

Not sure, maybe do a repeat until statement with something like:

repeat 
    wait(1)
    count = count + 1
    print(char.Count.Value)
until count.Value = (number to end at)

if you are doing a while true do statement and want it to end at a certain number, do:

while wait(1) do
count = count + 1
print(char.Count.Value)
if count.Value == whatever number then
    break
end

or something like that

Your increasing a variable, try this instead.

local count = char.Count

while wait(1) do
	count.Value = count.Value + 1
	print(char.Count.Value)
end
1 Like

This should be the answer, You can also write it shorter

local count = char.Count

while wait(1) do
	count.Value += 1
	print(count.Value)
end
2 Likes
while wait(1) do
  char.Count.Value = char.Count.Value + 1
  print(char.Count.Value)
end

lol, beat me to it, you have some fast typing skills

1 Like

Palms are sweaty, Copy pasta, Moms spaghetti

Although this prints the correct number, it does not increase the int value.

Could you link the api for “+=”? I cant find it sorry…

Maybe just make the count variable to

local count = char.Count.Value

into

local count = char.Count

so that in the while do statement, you can do count.Value = count.Value + 1
just a suggestion, if not than i can figure something out

1 Like

Its general code syntax and is used all around different languages. I recommend checking out this link

Additional info

+= is not defined in the first link. You can read more on it here

Look for lua_CFunction for an example

1 Like

Yes this is what I did, thank you <3

1 Like

np! gl with what you are working on!

1 Like