Do you need to use GetService, FindService or anything else in Server-Script?

do you need to use GetService, FindService or anything else in Server-Script ?

what do you mean by that, no you don’t NEED to use GetService for a script, it’s just a function that you can use to get a service.

i meant, is it useful to use GetService, FindService in a Server-Script

It’s typically good practice to use game:GetService on the server and the client for two reasons (although there could be more):

1- If a service is renamed, the correct service will still be returned.
2- If a service doesn’t exist yet, it’ll be created.

If a service doesn’t exist or is renamed and you try to index the game with that member using a period or square brackets (ie. game.Players, game[‘Run Service’]), you’ll get a “___ is not a valid member of DataModel” error.

1 Like

game:GetService(‘ServiceName’) is the best practice.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.