UserSettings

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

作成できません

ユーザー設定は、すべてのゲームにわたって持続する基本ユーザー設定を保管するために使用される単一オブジェクトです。現在、UserGameSettings オブジェクトのみを保存しています。

このオブジェクトへの参照を取得するには、UserSettings() 関数を使用して、それを返します。

コードサンプル

A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.

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

A LocalScript that demonstrates how you can detect whether a game is in full screen or not.

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)

A basic example that shows how you can listen to changes in the user's settings. With this code pasted into a LocalScript running in the StarterPlayerScripts, you can change settings in Roblox's game menu, and see their values appear in the output as detected changes.

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)

概要

方法

  • 指定されたユーザー機能が有効になっている場合は、真を返します。ユーザー機能が存在しない場合は、エラーが発生します。

  • Reset():()

    ユーザー設定の保存状態を消去し、デフォルト値を復元します。

ServiceProvider から継承した 方法
  • 並列書き込み

    指定された className によって指定されたサービスを返す、既に作成されている場合は無効な名前のエラー。

  • リクエストされたクラス名でサービスを返し、存在しない場合は作成します。

イベント

ServiceProvider から継承した イベント

プロパティ

方法

IsUserFeatureEnabled

指定されたユーザー機能が有効になっている場合は、真を返します。ユーザー機能が存在しない場合は、エラーが発生します。

この機能は、「ユーザー」で始まる FFlag のリストをチェックします。機能は Roblox が作成したスクリプトで使用することを目的としており、GlobalSettings:GetFFlag() と同様に機能します。

パラメータ

name: string
既定値: ""

戻り値

コードサンプル

A basic sample of how the IsUserFeatureEnabled function is used by Roblox to control certain features.

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

()

ユーザー設定の保存状態を消去し、値をデフォルトに戻します。この機能は、UserGameSettings クラスのすべてのプロパティを復元する権限がないため、ローカルスクリプトから正しく実行できません。


戻り値

()

イベント