We use cookies on this site to enhance your user experience

UserGameSettings Listener

UserGameSettings Listener

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.

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)