normalWay = game.Players
getScript = game:GetService("Players")
I just wanted to ask if there was a specific difference. Does it do the same thing as a :WaitForChild()?
normalWay = game.Players
getScript = game:GetService("Players")
I just wanted to ask if there was a specific difference. Does it do the same thing as a :WaitForChild()?
normalWay = game.Players
Will cause an error if the object, or whatever it is called, not present.
getScript = game:GetService("Players")
This will see if it is present, if not, it will create the service, and return it to you.
thesit was about 75% correct.
the problem with simply declaring:
local plrs = game.Players;
is that at the moment you index Players, the service Players may not have actually loaded in yet, which means you are now trying to index a nil value.
You should call game:GetService() first, because the :GetService method will wait until the service actually exists, and then it will return the service.
local plrs = game:GetService("Players");
I hope this helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
I may be wrong though, :) Just bare with it.
Well, the issue with the first one is that sometimes exploiters change the name of the service, sometimes to other texts or numbers, so the GetService function is your best friend in this situation, as it gets the service regardless of name. :)