Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

NumberValue Increasing by a strange amount?

Asked by 6 years ago

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:

1while true do
2    local num = script.Parent.Value
3    num.Value = num.Value + 1
4    print (num)
5    wait(1)
6end

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

Log in to vote
0
Answered by 6 years ago
01debounce = false
02while true do
03if not debounce then
04debounce = true
05    local num = script.Parent.Value
06    num.Value = num.Value + 1
07    print (num)
08    wait(1)
09    debounce = false
10end

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

0
pls upvote if it works Gameplayer365247v2 1055 — 6y
1
It didnt work for me DreamInspired 61 — 6y
0
still same result? Gameplayer365247v2 1055 — 6y
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. DreamInspired 61 — 6y
View all comments (3 more)
0
thanks Gameplayer365247v2 1055 — 6y
0
u can accept the answer tho Gameplayer365247v2 1055 — 6y
0
that gives me points Gameplayer365247v2 1055 — 6y
Ad
Log in to vote
0
Answered by
Aqu_ia 39
6 years ago

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,

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

or you could say,

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

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

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. DreamInspired 61 — 6y

Answer this question