game.Players.BanningEnabled does not Register as Boolean

When running the code below, I should expect to get a Boolean returned to my code.

if game.Players.BanningEnabled then

I instead receive the error below.
BanningEnabled is not a valid member of Players "Players"
image

The code that runs this can be found below.

Expected behavior

I expect to get a true or false statement depending if BanningEnabled is true or false. The property does not exist and as stated by Documentation, it should be able to be read in Parellel. This is not the case.

A private message is associated with this bug report

This is intentional - the documentation mentions that this property is not scriptable and therefore cannot be read from/written to by scripts. You can change the property manually in the Studio window.

1 Like

:wilted_flower: thank you for clarifying. This feels like a feature that should be readable, but I guess it can be detected from errors with :BanAsync. I should have read closer.

Edit

Made this code for Boolean behavior below:

local RuntimeService = game:GetService("RuntimeService")
local PlayerService = game:GetService("Players")

local function isBanningEnabled()
	local newUserId = tonumber(2)
	local config: BanConfigType = {
		UserIds = { newUserId },
		Duration = 1,
		DisplayReason = "BANNINGENABLED.",
		PrivateReason = "",
		ExcludeAltAccounts = false,
		ApplyToUniverse = true,
	}
	local success, err = pcall(function()
		return PlayerService:BanAsync(config)
	end)
	if success then
		return true 
	end
	return false 
end

if not RuntimeService:IsStudio() and isBanningEnabled() then

end
1 Like