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

Why is the Text not increasing in value each second? [closed]

Asked by 5 years ago
Edited 5 years ago

The locals are there in the original script its the 3rd line that is not working. for _ = 1,5 do

stats.Views.Value = stats.Views.Value + 1

script.Parent.Parent.Parent.Parent.pot.Text = "Views:".. 1 + i

wait(1)

end

0
You're using three dots instead of two. Two dots resemble Lua's concatenation symbol. DeceptiveCaster 3761 — 5y
0
Also, do not post duplicate questions. DeceptiveCaster 3761 — 5y

Marked as Duplicate by DeceptiveCaster, namespace25, Fifkee, and popeeyy

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Did you copy paste this without knowing what it does? The “i” variable commonly seen in loops isn’t magic, it is specified at the beginning, where you used an underscore instead. An underscore is commonly used as a “garbage variable” when we aren’t going to use the value, but that is not the case here! Fixed code:

for i = 1,5 do
      stats.Views.Value = stats.Views.Value + 1
      script.Parent.Parent.Parent.Parent.pot.Text = "Views:" .. 1 + i
      wait(1)
  end
  

Also maybe you’re typing this on a phone and not copy pasting directly but that was an ellipsis character between "Views:" and 1 + i there, where it should be two dots (..).

[Edit] I just saw your other question, you should use my code above, but adding an increment to i would also work with yours:

local i = 1 
  for i = 1,5 do    
      stats.Views.Value = stats.Views.Value + 1
      script.Parent.Parent.Parent.Parent.pot.Text = "Views:" .. 1 + i
      wait(1)   
      i = i + 1 
  end
  
0
stop giving misinformations mc ur giving us cancer. You don't use underscores for important variable names because it is misleading as it does not clearly show the purpose it is meant to serve in the code. So he is perfectly fine. User#24403 69 — 5y
Ad