The loop works fine for all but one problem--visualgui can only be referenced on the first loop. After that, I get an output message that says "attempt to index field '?' (a nil value)"
I'm guessing it has something to do with the fact that I'm restating what visualgui is on every loop. Could somebody explain why this script won't function?
while true do
wait(.5)
community = game.Players:GetChildren()
script.Bool.Value = true
for i = 1, #community do
substats = community[i].Speedstat:GetChildren()
for i = 1, #substats do
SUB = substats[i]
Effect(SUB)
TimeCheck(SUB)
HERE---- visualgui = community[i].PlayerGui.GameStats:FindFirstChild(SUB.Name)
print(visualgui.Name)
visualgui.Num.Text = SUB.Time.Value
if substats[i].Value == 1 or substats[i].Value == 3 then
timer = substats[i].Time
timer.Value = timer.Value - .5
end
end
end
end
|