BanPermissions is not a valid member of ServerScriptService "ServerScriptService"

I’m not going to really explain what I’m making as it has no use in this.

Its saying the BanPermissions is not a valid member of ServerScriptService when it is. I used a module script for the ban permissions, the thing that requires it is also in SSS.
SSS - BanServerScript (LocalScript)

local DataStoreService = game:GetService("DataStoreService")
local PermanentBanDataStore = DataStoreService:GetDataStore("PermanentBanDataStore")
local TemporaryBanDataStore = DataStoreService:GetDataStore("TemporaryBanDataStore")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent_BanPlayer = ReplicatedStorage:WaitForChild("RemoteEvent_BanPlayer")

local BanPermissions = require(game.ServerScriptService.BanPermissions)

local function calculateBanDuration(banType)
	if banType == "temp_1day" then
		return 1 * 24 * 60 * 60 
	elseif banType == "temp_3days" then
		return 3 * 24 * 60 * 60 
	elseif banType == "temp_5days" then
		return 5 * 24 * 60 * 60
	end

	return nil
end
RemoteEvent_BanPlayer.OnServerEvent:Connect(function(player, targetPlayer, banType, banReason)
	if not BanPermissions.HasBanPermission(player, banType) then
		print("Player '" .. player.Name .. "' does not have permission to ban.")
		return
	end

	targetPlayer = game.Players:FindFirstChild(targetPlayer)
	if not targetPlayer then
		
		print("Player '" .. targetPlayer .. "' not found.")
		return
	end

	local banData = {
		Reason = banReason,
		Timestamp = os.time(),
		BannedBy = player.Name
	}

	if banType:sub(1, 5) == "temp_" then
		local banDuration = calculateBanDuration(banType)
		if banDuration == nil then
			print("Invalid temporary ban type.")
			return
		end

		print("Banning player '" .. targetPlayer.Name .. "' temporarily with reason: " .. banReason .. " (Duration: " .. (banDuration / (60 * 60 * 24)) .. " days)")

		
		local success, err = pcall(function()
			TemporaryBanDataStore:SetAsync(targetPlayer.UserId, banData)
		end)

		if not success then
			print("Error saving temporary ban data for player '" .. targetPlayer.Name .. "': " .. err)
		end
	elseif banType == "perm" then

		print("Banning player '" .. targetPlayer.Name .. "' permanently with reason: " .. banReason)


		local success, err = pcall(function()
			PermanentBanDataStore:SetAsync(targetPlayer.UserId, banData)
		end)

		if not success then
			print("Error saving permanent ban data for player '" .. targetPlayer.Name .. "': " .. err)
		end

		
	
		targetPlayer:Kick("You have been permanently banned. Reason: " .. banReason)
	end
end)

local BanPermissions = {}

local rankPermissions = {
	Admin = {
		tempBan = true,
		permBan = false
	},
	HeadAdmin = {
		tempBan = true,
		permBan = true
	},
	Owner = {
		tempBan = true,
		permBan = true
	},
	CoOwner = {
		tempBan = true,
		permBan = true
	}
}
**SSS - BanPermissions (ModuleScript)**
local function getRankOfPlayer(player)
	local YourRankData = {
		["Player1"] = "Admin",
		["Player2"] = "HeadAdmin",
		["Comqts"] = "Owner",
		["Player4"] = "CoOwner",
	}

	local username = player.Name

	if YourRankData[username] then
		return YourRankData[username]
	else
		return "DefaultRank"
	end
end

local function hasBanPermission(player, banType)
	local rank = getRankOfPlayer(player)
	local permissions = rankPermissions[rank]

	if not permissions then
		return false
	end

	if banType == "temp" then
		return permissions.tempBan
	elseif banType == "perm" then
		return permissions.permBan
	else
		return false
	end
end

BanPermissions.HasBanPermission = hasBanPermission

return BanPermissions

Use WaitForChild

local BanPermissions = require(game.ServerScriptService:WaitForChild("BanPermissions")

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.