UserSettings

사용되지 않는 항목 표시
만들 수 없음

UserSettings is a singleton object that is used to house basic user settings, which persist across all games. Currently, it only stores the UserGameSettings object.

You can retrieve a reference to this object via the UserSettings() function, which returns it.

코드 샘플

IsUserFeatureEnabled Sample

if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' should no longer be loaded from the CameraScript!")
else
print("'ClickToMove' is still loaded from the CameraScript!")
end
Full Screen Mode Detection

local gameSettings = UserSettings().GameSettings
local function checkFullScreenMode()
local inFullscreen = gameSettings:InFullScreen()
if inFullscreen then
print("Full Screen mode enabled!")
else
print("Full Screen mode disabled!")
end
end
checkFullScreenMode()
gameSettings.FullscreenChanged:Connect(checkFullScreenMode)
UserGameSettings Listener

local gameSettings = UserSettings().GameSettings
local function onGameSettingChanged(nameOfSetting)
-- Fetch the value of this setting through a pcall to make sure we can retrieve it.
-- Sometimes the event fires with properties that LocalScripts can't access.
local canGetSetting, setting = pcall(function()
return gameSettings[nameOfSetting]
end)
if canGetSetting then
print("Your " .. nameOfSetting .. " has changed to: " .. tostring(setting))
end
end
gameSettings.Changed:Connect(onGameSettingChanged)

요약

메서드

  • Returns true if the specified user feature is enabled. This will throw an error if the user feature does not exist.

  • Reset():void

    Erases the saved state of the UserSettings, and restores its default values.

메서드ServiceProvider에서 상속되었습니다
  • 병렬 쓰기

    Returns the service specified by the given className if it's already created, errors for an invalid name.

  • Returns the service with the requested class name, creating it if it does not exist.

이벤트

이벤트ServiceProvider에서 상속되었습니다

속성

메서드

IsUserFeatureEnabled

Returns true if the specified user feature is enabled. This will throw an error if the user feature does not exist.

This function checks against a list of FFlags, whose name starts with "User". The function is intended to be used by Roblox-created scripts, and functions similarly to GlobalSettings:GetFFlag().

매개 변수

name: string

반환

코드 샘플

IsUserFeatureEnabled Sample

if UserSettings():IsUserFeatureEnabled("UserNoCameraClickToMove") then
print("'ClickToMove' should no longer be loaded from the CameraScript!")
else
print("'ClickToMove' is still loaded from the CameraScript!")
end

Reset

void

Erases the saved state of the UserSettings, and restores its values back to default. This function will fail to run correctly from a LocalScript, as it does not have permission to restore all of the properties in the UserGameSettings class.


반환

void

이벤트