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

NumberValue , Is this the way how to add 1 to it? [ANSWERED]

So, Ive made many questions about this topic but I still don't understand. I have made a script myself to test it out a little bit. This is what I made.

local Temp = game.Workspace.Temp.Value

while true do
	wait(2)
	Temp = Temp + 1
end

But It doens't seem to work. What I want to do is make it add +1 to the NumberValue called "Temp" every 2 seconds. Anyone knows what is wrong?

Best Regards, kyanoke11

1 answer

✓ Accepted answer

You are adding 1 to the variable Temp not the NumberValue object's value. When you do

local Temp = game.Workspace.Temp.Value

It sets Temp to the NumberValue's value. Then you are adding 1 to the Temp variable with your loop.

What you need to do is this

local Temp = game.Workspace.Temp
 
while true do
    wait(2)
    Temp.Value = Temp.Value + 1
end

2 comments

0

Thank You! - Question answered

0

No Problem

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