So I have a variable, _G.have. How do I make this global variable appear in my StarterGui code??
Code in starter:
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 |
04 | mouse.Button 2 Down:Connect( function () |
05 | print (_G.have) |
06 | if _G.have = = true then |
07 | player.Character.Weld:Destroy() --ignore these |
08 | _G.have = false |
09 | end |
10 | end ) |
It just prints nil, can someone please tell me how to make global variables in starterGui???
Hi there, before I begin I want to apologize for my minimal brain activity, it’s 02:27 here, anyways,
_G is what’s known as a global table, what matters is that it’s not very global the way we use it, it depends on the lua state and other stuff, all you need to know is:
_G does not transfer between scripts with different context values, and in your case, the main problem, is that _G does not transfer between the server and client, you cannot use it for server-client variable transferring.