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

local global variable returns nil, bug?

Asked by 6 years ago

Declared in another script:

_G.Stamina = 100

The script that uses it and says "comparing number to nil"

local SBar = script.Parent:WaitForChild("BackG"):WaitForChild("SBar")
while _G.Stamina > 0 and wait(.1) do
    print "test"
    SBar:TweenSize(UDim2.new(0, _G.Stamina/100, 0, 1, 0), "Out", "Quint", .1, true)
end

while true and wait(.1) do
    wait(.1)
    local print = "s"
end

Is this a bug or am I doing something wrong here?

0
You can't get `_G` variables in a LocalScript if you're using one, or it might be the case of that the script loaded before the variable, in which case you'd do `while not _G.Stamina do wait(1/8) end` TheeDeathCaster 2368 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

This is just a bug you have to reset roblox studio and it will be working again.Your welcome.I will aresiate it if you submit this awnser as the oficial awnser

0
Resetting Roblox studio did not help, I have tried it before, and now I tried it again. That is not the solution to my problem. Omega677 15 — 6y
0
oh sorry im just saying random stuff to get my rank higher..as you can see im in negative 9 right now and i dont like being in negatives.........Thats why you will see me asking random questions and posting random awnsers. srry User#20192 0 — 6y
0
This would fit better as a comment rather than a question. TheeDeathCaster 2368 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

The variable had not been declared before it was called, not a bug.

Answer this question