Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Adonis custom commands lead to error(attempted to index nil with finddfirstchild ) how to fix?

Asked by 1 year ago

The command runs is able to be called in game but leads to the nil error.


server.Commands.SetAge = {
    Prefix = server.Settings.Prefix;
    Commands = {"setage","SetAge"};
    Args = {"player","value"};
    Description = "Set player Rank Value (1-100)";
    AdminLevel = "Owners";
    Function = function(plr,args)
        if not args[1] and args[2] then error("Argument missing or nil") end
        if not tonumber(args[2]) then error("Argument 2 is not a valid number") end
        local folders = service.ServerStorage:FindFirstChild(".stats")
        for i,v in pairs(service.GetPlayers(plr,args[1])) do
            local playerFolder = folders:FindFirstChild(v.Name)
            if playerFolder then
                local Data = playerFolder:FindFirstChild('Age')
                if Data then
                    Data.Value = tonumber(args[2])
                    v:LoadCharacter()
                    server.Functions.Hint("Set "..tostring(v).." age to     "..tostring(args[2]),{plr})
                else
                    error("No weapon data value found")
                end
            else
                error("Could not find data for "..tostring(v))
            end
        end
    end
}
0
Which line is error coming from? Sabailuridze 126 — 1y
0
It does not tell me as its an error i receive in game from adonis but i would assume line 10, i can send a picture on discord if you would like to see Olus#6111 Nechga3 0 — 1y
0
Looks like there's no folder in ServerStorage called ".stats" Ziffixture 6913 — 1y
0
thanks it seems like i put the data in the wrong area Nechga3 0 — 1y

Answer this question