DasKairo
(Cairo)
January 8, 2023, 4:42am
#1
I was messing around with DataModel
and i stumbled across FindService
, it appears to do the exact same thing as GetService
with only one difference, if the Service isn’t found, it will error, but with GetService
, it creates a Service if it doesnt exist, so:
game:GetService()
or game:FindService()?
FindService
GetService
game:GetService("Workspace") -- Creates new if Service not found
game:FindService("Workspace") -- Errors if Service not found
TheSai_ki
(CIover)
January 8, 2023, 5:30am
#3
Your question has already been answered here:
As it has been stated in this thread, :FindService will only return the service if it exists, although :GetService does the same thing, it will create the service if it doesn’t already exist. Normally there are a few services that are already existing on run which may be retrieved by :FindService so I made a list of:
Services that exist at runtime Service
Exists on the Server
Exists on the Client
<a href="https://developer.roblox.com/api-reference/class/Workspace">Workspace&l…
2 Likes
DasKairo
(Cairo)
January 8, 2023, 5:32am
#4
Woops, I forgot that I made this topic, I was going to say that I found this but I was focused on other things, thanks tho
TheSai_ki
(CIover)
January 8, 2023, 5:34am
#5
I think that :FindService()
Might be depreciated, but hasn’t been labeled as so officially yet.
xDeltaXen
(xDeltaXen)
January 8, 2023, 8:26am
#6
GetService will create a service that doesn’t exist. FindService will not.
1 Like