Can a script disable / turn on another script? how?
Suppose a script, script A is turned off by another script, script B. Then script B turns script A back on. Are all previous variable values of script A, now that it is turned back on, lost? This can be quite a problem. How can one share variables between script A and script B then?
As cailir said use .disable to disable a script ex:
game:GetService("Workspace"):WaitForChild("Script").disable
One way to share variables between scripts (note: these variables only share through severscript to serverscript so if you want it to go from serverscript to localscript use a RemoteFunction)
You can use a global variable using _G.variable to set the variable do
._G.text = "string"
to retrieve the variable simple do
_G.text
Bonus:
I felt like giving you a little something extra, You learnt Global Variables and now you can learn global functions. For example instead of doing
function idk() wait(4) return "idk" end
You can instead let that be called in any serverscript if its in a serverscript
_G.idk = function() wait(4) return(idk) end
to call this function do
_G.idk()