Module Script :

local module = {}
local plr = game.Players.LocalPlayer
local data = game:GetService("DataStoreService")
local bandata = data:GetDataStore("banned")
local usid = plr.UserId


--//functions\\--

	game.Players.PlayerAdded:Connect(function()
		local banned
		local succes, errormessage = pcall(function()
			bandata:GetAsync(usid)
		end)
		if banned == true then
			plr:Kick("You are banned")
		end
	end)



function module.ban(usid)
	local success, errormessage = pcall(function()
		bandata:SetAsync(usid, true)
	end)
	if success then
		print(usid + " Banned.")
	end
end
end

return module

OutPut : Workspace.nematknprotect.Credit.SettingsAyarlar:13: attempt to index nil with 'UserId'

Please help!

3 comments

0

is the module script required by a localscript? or server script?

0

server script

0

That will be why. If a module is used by a server script, it acts like a server script