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

4 comments
so how should I avoid this?
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.
when I type it all out and then type play solo it only will load to about fifty percent and then roblox stops working
Oh, That's actually taking work on your computer. Why not be in game and press F9 its the dev Console.