New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Player.CharacterAdded is a nil value?

Asked by
Blob_y 2
1 year ago
Edited 1 year ago

So this is the script I'm using error occurs at line 219 The script is a module script I don't know if that useful information I'm pretty new to scripting so any help will be huge, thanks :) --This is the error code 16:34:30.450 - ServerScriptService.Server.AdminCommands:113: attempt to index field 'CharacterAdded' (a nil value)

``` local m = {}

game.Players.PlayerAdded:Connect(function(player)

player.Chatted:connect(function(msg, r)

if r then return end

m.parse(msg, player)

end)

end)

--Services

local dstore=game:GetService("DataStoreService")

--Setup Variables

m.database=dstore:GetDataStore("adminCommands")

m.adminList={-- List of userids used for first time admin use

24034877;

-1

}

m.commamndStart="!"--What user uses to start commands

local aList

pcall(function()

aList = m.database:GetAsync("adminList")

end)

if not aList then

m.database:SetAsync("adminList",m.adminList)

aList=m.adminList

end

--setup parse function

function m.parse(msg, player)

local playerIsAdmin

for a,b in pairs(aList) do

playerIsAdmin=b==player.UserId

if playerIsAdmin then break end

end

if playerIsAdmin then

if msg:sub(1, 1)==m.commamndStart then

if #msg==1 then

warn("Just command signature, consider entering a command")

else -- parse rest

local line=msg:sub(2,#msg)

local command,arguments=nil,{}

for a in line:gmatch("[%w%p]+") do

if command==nil then command=a else table.insert(arguments,a) end

end

if m.commands[command] then -- command exists

m.commandscommand

else -- command doesn't exist

warn("No command titled"..command.."exists")

end

end

end

end

end

m.commands={

addAdmin=function(arg,caller)

for a,b in pairs(arg) do

if tonumber(b) then

print("Added Admin "..b)

table.insert(aList,tonumber(b))

m.database:SetAsync("adminList", aList)

else

local userid=game.Players:GetUserIdFromNameAsync(b)

if userid then

print("Added Admin"..b)

table.insert(aList,userid)

m.database:SetAsync("adminList", aList)

else

m.warn("addAdmin","Player Name\" "..b.."\" is not a valid player")

end

end

end

end;

removeAdmin=function(arg, caller)

for a,b in pairs(arg) do

if tonumber(b) then

print("Removed Admin"..b)

for d,c in pairs(aList) do

if c ==tonumber(b) then

table.remove(aList,d)

break

end

end

m.database:SetAsync("adminList", aList)

else

local userid=game.Players:GetUserIdFromNameAsync(b)

if userid then

print("Removed Admin "..b)

for d,c in pairs(aList) do

if c ==userid then

table.remove(aList,d)

break

end

end

m.database:SetAsync("adminList", aList)

else

m.warn("removeAdmin","Player Name\" "..b.."\" is not a valid player")

end

end

end

end;

print=function(arg,caller)

for a,b in pairs(arg) do

print(b)

end

end;

GreyPotion=function(player)

local clone = game.ReplicatedStorage.GreyPotion:Clone()

local Character = player.Character or player.CharacterAdded:wait()

clone.Parent = workspace

clone.CFrame = Character.HumanoidRootPart.CFrame

end;

}

--Setup Custom Error function

function m.warn(cmd, issue)

warn("In command"..m.commandStart..cmd.."issues occured, receipt:"..issue)

end

--Require

return m ```

0
das a long script CjayPlyz 580 — 1y

Answer this question