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

accessing global variable crashing game?

Asked by 9 years ago

I have written a piece of code that is in two different scripts, one changes the variable and the other reads it.

script one

closed = game.Workspace.closePressed

function closeGui()

closed = false

end

script two

closed = game.Workspace.closePressed

if closed == true then
...

end
else if closed == false then

end

2 answers

Log in to vote
2
Answered by 9 years ago

I'm not sure what you're getting at here, as you have very little code provided, but there is a problem with script two, and that's that you have ended the if statement before you introduced the elseif.

Corrected code:

closed = game.Workspace.closePressed

if closed == true then
...
elseif closed == false then --there is no space in "elseif", that is another problem.
...
end

Ad
Log in to vote
0
Answered by
Subbix -5
9 years ago

Oh, Yeah that happens some times. btw the global function is _G

0
so how should I avoid this? CaptainRuno 40 — 9y
0
Well mostly i think its else if change that to elseif and may you put the output so i can see what's wrong? Well, If you can. Subbix -5 — 9y
0
when I type it all out and then type play solo it only will load to about fifty percent and then roblox stops working CaptainRuno 40 — 9y
0
Oh, That's actually taking work on your computer. Why not be in game and press F9 its the dev Console. Subbix -5 — 9y

Answer this question