Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

_G Help? Kinda Complicating

Asked by
KAAK82 16
10 years ago

I see it in a lot of Scripts... and I once saw it in Youtubes' Mouse Sensitivity Script... _G Mouse.Sensitivity = 0.5 etc... so plz help me with the meaning...

1 answer

Log in to vote
3
Answered by
Maxomega3 106
10 years ago

Funny you should post something about that minutes after I ask about it, lol.

_G is a way to declare and index variables and functions throughout your entire place. If you declare a _G function in one script, and use it in another, the place will know what to do.

Format:

_G['FunctionName'] = function (parameter)
--stuff
end

Example:


--Script 1 _G{'AddNumbers'] = function (num1,num2) return num1 + num2 end -- Script 2 print (_G.AddNumbers (3,4))

Output will be 7

~Just remember that if someone answers your question you and that person will get reputation if you accept their answer. There should be a button for it near the voting on the answer. ~

0
I know lol... I like ur answer even though kinda confusing lol... also, could u plz tell me about Youtube's Mouse Sensitivity Script, y there's _G? KAAK82 16 — 10y
0
Thanks. I never understood that. +1 Orlando777 315 — 10y
0
Mouse Sensitivity was probably a function the user on Youtube was trying to manipulate via _G functions. _G is not directly related to Mouse Sensitivity, but if you want, I can help you try to comprehend it if you post the code on a new thread. Maxomega3 106 — 10y
0
It should also be noted that LocalScripts cannot access the _G used by scripts. Articulating 1335 — 10y
Ad

Answer this question