Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

NumberValue Increasing by a strange amount?

I am trying to make a numbervalue increase by one everytime a tool is activated, but for some reason the number that im increasing the numbervalue by increases by 1 everytime the tool is activated, instead of increasing the numbervalue. Ex:

while true do
    local num = script.Parent.Value
    num.Value = num.Value + 1
    print (num)
    wait(1)
end

Output: 1 2 4 7 11 ...and so on...

Here is my code, I am referring to the part where is says "elseif y.Name=v.name" https://gyazo.com/8a71086d0b984838610372510ab67191

2 answers

✓ Accepted answer
debounce = false
while true do
if not debounce then
debounce = true
    local num = script.Parent.Value
    num.Value = num.Value + 1
    print (num)
    wait(1)
    debounce = false
end

this makes it so the code cant run multiple times at once and u will only get + 1 value for each time

7 comments

0

pls upvote if it works

1

It didnt work for me

0

still same result?

1

Actually, I used debounce but I didnt use it the way you said. I will still upvote you when my reputation is high enough. Thank you.

0

thanks

0

u can accept the answer tho

0

that gives me points

I think your problem is that you have already described what the value is. Your script is: while true do local num = script.Parent.Value num.Value = num.Value + 1 print (num) wait(``1``) end You have already said that the num is the script.Parent.Value. If you use num.value, it'll not worked because num already has the value in it. So try,

while true do
local num = script.Parent
num.Value = num.Value + 1

or you could say,

while true do
local numb = script.Parent.Value
num = num + 1

As I have said before, I am not very experienced with scripting, but I think this should help.

1 comment

0

The script.parent isnt a numbervalue its a meshpart. The numbervalue is in the meshpart therefor script.Parent is a meshpart and the value is the child of the meshpart.

This discussion is preserved as it was. New answers, comments, and votes are closed.