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 5 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:

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

Log in to vote
0
Answered by 5 years ago
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

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

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.

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 — 5y

Answer this question