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

accessing global variable crashing game?

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

✓ Accepted answer

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

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

4 comments

0

so how should I avoid this?

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.

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

0

Oh, That's actually taking work on your computer. Why not be in game and press F9 its the dev Console.

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