so i wanna make it add numbers automatically like the target number is 100 and the stringvalue is 25 then with a script it'll automatically add the needed numbers for it to be 100, this is what i've come up to but its not what on my mind
for i=1, numberheretoreachthetargetnumber do target = game.Players.LocalPlayer.Part if target.Value ~= 100 then n.Value + 1 end end
Not sure if this is what you were asking, but I'll try to explain anyway. Let me know if this is not what you wanted. Since you're dealing with numbers you might want to use a numbervalue instead of a string value.
Is target a StringValue
? You mention wanting to change a StringValue
but it seems like target is a Part if I didn't know any better. I'm going to assume target is a string value.
Your current script almost works.
You are attempting to add 1 to target's value until the value reaches 100. Since target is a StringValue, n.Value + 1
will fail because you are trying to add a number to a StringValue.
You also did not define the variable n anywhere. You need to convert the stringvalue to a number to add one, and then convert it back to a string.
You also don't have a wait() anywhere so your code will run instantaneously adding up everything without any hesitation..
**You could do this instead, I included comments to explain the code. **
local myStringValue = workspace.StringValue local targetNumber = 100 --since myStringValue is a string, we need to convert it to a number local startingNumber = tonumber(myStringValue.Value) --start at myStringValue's number and then add 1 every second until we reach our target number for i = startingNumber, targetNumber do wait(1) myStringValue.Value = tostring(startingNumber + 1) end incrementingNumber = false