기타/Roblox Term

ServiceProvider:GetService

Roblox_개발자 2021. 4. 21. 16:38

developer.roblox.com/en-us/api-reference/function/ServiceProvider/GetService

 

ServiceProvider:GetService

This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on t

developer.roblox.com

설명:
요청된 클래스 이름을 가진 서비스를 반환합니다. 서비스 이름(예: 이물질)을 사용하여 호출하면 해당 서비스의 인스턴스가 반환됩니다. 서비스가 아직 존재하지 않으면 서비스가 생성되고 새 서비스가 반환됩니다. 이 방법은 일부 서비스를 만드는 유일한 방법이며, RunService의 이름은 "RunService"와 같은 비정상적인 이름을 가진 서비스에 사용할 수도 있습니다.

메모:
className 매개 변수가 기존 클래스이지만 클래스가 서비스가 아닌 경우 이 함수는 0을 반환합니다.
다른 개체 아래에 있는 서비스를 가져오려고 하면 "싱글톤 서비스 이름이 이미 있습니다"라는 오류가 발생합니다.