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
}

4 comments

0

Which line is error coming from?

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

0

Looks like there's no folder in ServerStorage called ".stats"

0

thanks it seems like i put the data in the wrong area