generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: GetService vs Selecting

Previous Thread :: Next Thread 
cntkillme721 is not online. cntkillme721
Joined: 17 Sep 2009
Total Posts: 351
19 Apr 2013 05:42 PM
Difference between:

game:GetService("Lighting")
(AND)
game.Lighting
Report Abuse
RyanDolan123 is not online. RyanDolan123
Joined: 05 Mar 2009
Total Posts: 17919
19 Apr 2013 05:48 PM
Some services need GetService in order to be accessed

I think the ContentProvider service is one of them






And that's it

~Kill The Clones is the best game on ROBLOX!~
Report Abuse
Dialoghack is not online. Dialoghack
Joined: 01 Feb 2011
Total Posts: 27
19 Apr 2013 05:50 PM
Also, GetService returns the service even if it's been renamed.

~ Dekkonot ~
Report Abuse
cntkillme721 is not online. cntkillme721
Joined: 17 Sep 2009
Total Posts: 351
19 Apr 2013 05:53 PM
kk
Report Abuse
woot3 is not online. woot3
Joined: 10 Nov 2008
Total Posts: 3599
19 Apr 2013 06:49 PM
Unless there is Service in the name, I generally don't use :GetService()
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
19 Apr 2013 06:59 PM
I always use GetService for everything, even players. After discovering that localscripts run before they're even descendants of the game, I'm kind of paranoid about everything.
Report Abuse
Aerideyn is not online. Aerideyn
Joined: 16 Jan 2010
Total Posts: 1882
20 Apr 2013 12:15 AM
as for local scripts i normaly just go:

repeat wait() until game.Players.LocalPlayer.Character

Because by the time the character is loaded - you are pretty safe to do what you like.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
20 Apr 2013 12:22 AM
I _always_ use GetService, save for the special case of Workspace which is already a variable in the default environment.
Report Abuse
coplox is not online. coplox
Joined: 07 Jun 2008
Total Posts: 3252
20 Apr 2013 12:36 AM
I always use GetService as well. Because I'm obsessed with my scripts working even in certain uncommon circumstances.
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
20 Apr 2013 07:21 AM
@Aerideyn
Game.Players.LocalPlayer.CharacterAdded:wait() -- why not this instead? :o


@coplox
Soooo true :o
Report Abuse
itunes89 is not online. itunes89
Joined: 19 Jan 2011
Total Posts: 1957
20 Apr 2013 07:27 AM
@ Aerideyn I use the same thing.

@nairod7 That works? Hmm, I'll try it.
Report Abuse
woot3 is not online. woot3
Joined: 10 Nov 2008
Total Posts: 3599
20 Apr 2013 07:46 AM
>@Aerideyn
>Game.Players.LocalPlayer.CharacterAdded:wait() -- why not this instead? :o

What if the Character already exists?
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
20 Apr 2013 07:50 AM
I do this to make sure the character exists:

if not Character then
Players.LocalPlayer.CharacterAdded:wait()
end

Annoying even more is the fact that PlayerGui doesn't exist in other Players if you're localside, only your own player - but is visible in the server.

After a few rounds of infinite yields, I figured this out. -__-

Pretty much, I don't trust anything in ROBLOX to be there that a user can conceivable change, or the admins can (that is, will) change. My scripts generate a lot of their stuff, and depend upon a client script to send it to them for the rest. :D

AKA Don't trust ROBLOX
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
20 Apr 2013 07:51 AM
adahell...

local player = Game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()

>.<...
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
20 Apr 2013 11:10 AM
Totally OT, Need help:
http://www.roblox.com/Forum/ShowPost.aspx?PostID=95209119
Report Abuse
coplox is not online. coplox
Joined: 07 Jun 2008
Total Posts: 3252
20 Apr 2013 12:16 PM
You know, that's one of my bad habits. When I handle a part, I always think "What if the part was removed RIGHT NOW via some skid"

So I need to realise that it doesn't matter if my game breaks when a skid invades, it just needs to work normally.
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
20 Apr 2013 12:30 PM
function waitForProp(obj, prop)
repeat wait() until obj[prop]
return obj[prop]
end

waitForProp(game:GetService("Players"), "LocalPlayer")
waitForProp(game:GetService("Players").LocalPlayer, "Character")

~ Dekkonot ~
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
20 Apr 2013 12:45 PM
or...

player.CharacterAdded:wait()
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
20 Apr 2013 12:48 PM
._. That works too, I guess.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
20 Apr 2013 02:26 PM
I've had issues in the past with CharacterAdded.

The snippet `local Character = Player.Character or Player.CharacterAdded:wait()` would, in theory, be the perfect solution. I used it quite often, but started encountering issues where the thread would yield indefinitely due to a brief moment of time before the Character property has been set, but after the script runs. The Character would not be found, and the event would not fire for some reason. Adding a `Wait(1)` to the top of the script did fix this, but I find that to be extraordinarily ugly.
Report Abuse
HEAT507 is not online. HEAT507
Joined: 31 Aug 2012
Total Posts: 429
20 Apr 2013 03:20 PM
users=game:service'Players';
userl=users.localPlayer;
userl.characterAdded:wait();
Report Abuse
cntkillme721 is not online. cntkillme721
Joined: 17 Sep 2009
Total Posts: 351
20 Apr 2013 05:35 PM
My questions have been answered. This forum has officially gained adhd.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
20 Apr 2013 05:46 PM
GetService will not work for JointsService
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
20 Apr 2013 06:36 PM
That's most likely because it's not *technically* a service.

~ Dekkonot ~
Report Abuse
Voxility is not online. Voxility
Joined: 15 Apr 2013
Total Posts: 584
20 Apr 2013 09:25 PM
I like to use a deprecated service ':service' instead of ':GetService' because its shorter :s.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image