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

local global variable returns nil, bug?

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?

2 comments

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

2 answers

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

3 comments

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.

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

0

This would fit better as a comment rather than a question.

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

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