Unable to assign property ShirtTemplate. Content expected, got nil

Im trying to load clothing ( pants and shirt ) but I always get this error:

Unable to assign property ShirtTemplate. Content expected, got nil 

Code:

local DataStoreService = game:GetService("DataStoreService")
local ShirtStore = DataStoreService:GetDataStore("ShirtStore")
local PantsStore = DataStoreService:GetDataStore("PantsStore")





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

	
	
	
	player.CharacterAdded:Connect(function(character)
		
		
		
		local success, ShirtID = pcall(function()

			ShirtStore:GetAsync(player.UserId)

		end)

		if success then 
			print("Shirt Loaded!")
			
			player.Character.Shirt.ShirtTemplate = ShirtID
		end
		
		local success1, PantsID = pcall(function()

			PantsStore:GetAsync(player.UserId)

		end)

		if success1 then 
			print("Pants Loaded!")
			
			player.Character.Pants.PantsTemplate = PantsID
		end
		
		
		
		
		
	end)
	
	
	
	
	
end)



	

It means that ShirtID is nil. The reason why is because you have misused the second argument of a pcall. The second argument is errormessage - which means that if success is false, errormessage will have an error message (which you can print to the terminal), and if its true, then errormessage will be nil. This is what’s happening in your case. You need to remove the ShirtID from the pcall argument stage, and place it inside the pcall itself or somewhere else appropriate.

1 Like

Thank you it solved the problem!

No problem! Glad I could help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.