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 10 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

1closed = game.Workspace.closePressed
2 
3function closeGui()
4 
5closed = false
6 
7end

script two

1closed = game.Workspace.closePressed
2 
3if closed == true then
4...
5 
6end
7else if closed == false then
8 
9end

2 answers

Log in to vote
2
Answered by 10 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:

1closed = game.Workspace.closePressed
2 
3if closed == true then
4...
5elseif closed == false then --there is no space in "elseif", that is another problem.
6...
7end
Ad
Log in to vote
0
Answered by
Subbix -5
10 years ago

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

0
so how should I avoid this? CaptainRuno 40 — 10y
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 — 10y
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 — 10y
0
Oh, That's actually taking work on your computer. Why not be in game and press F9 its the dev Console. Subbix -5 — 10y

Answer this question