System wont load texture? - Accessory insert system

Hello devforum,

I’m currently working on a system that allows players to import shirts, pants & accessories.
The system support decal clothing, and I’m currently trying to get the system to load custom textures onto accessories.

For some reason this isn’t working, even though it should be loading the decal with the texture needed.
Here’s the server script:

local event = game.ReplicatedStorage.Accessories.SendInfo
local insertService = game:GetService("InsertService")

event.OnServerEvent:Connect(function(player, id, mode, texid)
	local model = insertService:LoadAsset(id)
	model.Parent = workspace
	local asset = model:GetChildren()[1]
	if mode == "Hat" then
		if asset:IsA("Accessory") then
			if texid == not "" then
				local texturemodel = insertService:LoadAsset(texid)
				texturemodel.Parent = workspace
				local texasset = texturemodel:GetChildren()[1]
				asset.Handle.Texture = texasset.Texture
				player.Character.Humanoid:AddAccessory(asset)
				texturemodel:Destroy()
			else
				player.Character.Humanoid:AddAccessory(asset)
			end
		end
	elseif mode == "Shirt" then
		if asset:IsA("Shirt") then
			if player.Character:FindFirstChildWhichIsA("Shirt") then
				player.Character:FindFirstChildWhichIsA("Shirt"):Destroy()
			end
			asset.Parent = player.Character
		end
		if asset:IsA("Decal") then
			if player.Character:FindFirstChildWhichIsA("Shirt") then
				local shirt = player.Character:FindFirstChildWhichIsA("Shirt")
				shirt.ShirtTemplate = asset.Texture
			else
				local shirt = Instance.new("Shirt", player.Character)
				shirt.ShirtTemplate = asset.Texture
			end
		end
	elseif mode == "Pants" then
		if asset:IsA("Pants") then
			if player.Character:FindFirstChildWhichIsA("Shirt") then
				player.Character:FindFirstChildWhichIsA("Shirt"):Destroy()
			end
			asset.Parent = player.Character
		end
		if asset:IsA("Decal") then
			if player.Character:FindFirstChildWhichIsA("Pants") then
				local pants = player.Character:FindFirstChildWhichIsA("Pants")
				pants.PantsTemplate = asset.Texture
			else
				local pants = Instance.new("Pants", player.Character)
				pants.PantsTemplate = asset.Texture
			end
		end
	end
	asset:Destroy()
	model:Destroy()
end)

and here’s the localscript for the GUI if there’s any issues with it:

local textbox = script.Parent.main
local textButton = script.Parent.add
local event = game.ReplicatedStorage.Accessories:WaitForChild("SendInfo")
local Tbx = script.Parent.texturesbox

-- moding
local mode = "Hat"
local PantsButton = script.Parent.pantsmode
local ShirtsButton = script.Parent.shirtsmode
local HatsButton = script.Parent.Hatsmode

PantsButton.MouseButton1Click:Connect(function()
	mode = "Pants"
	print("Set mode to Pants")
	Tbx.Visible = false
end)

ShirtsButton.MouseButton1Click:Connect(function()
	mode = "Shirt"
	print("Set mode to Shirt")
	Tbx.Visible = false
end)

HatsButton.MouseButton1Click:Connect(function()
	mode = "Hat"
	print("Set mode to Hat")
	Tbx.Visible = true
end)

textButton.MouseButton1Click:Connect(function()
	event:FireServer(textbox.Text, mode, Tbx.Text)
	print("Sent info!")
end)

Tbx.Text = ""

The if statement that adds the detection and loading of the texture now just completely stops the accessory from loading, and I can only assume that means the texture doesn’t work either.

If you have any possible solutions, please reply.

Update:
I have seen the mistake that deletes the accessory, however the texture still does not load.
(Mistake was asset:Destroy() at the end of the serverscript)

But, the custom texture when inputted, does not load on the accessory, how do I fix this?

Hi! So for loading in textures, I generally like to do:

 "rbxassetid://" .. id

Have you tried to see if there is any change when doing this? Hope this helps!

Hey,
I’ve tried this by changing the texture addition line to asset.Handle.Texture = "rbxassetid://" ..texasset.Texture however this hasn’t worked.

I might try it again when i get home in a few hours but it doesn’t seem like it worked correctly.

Alright, I’ve tested this further and have identified the main issue.

I’ve flipped the if statement that determines if there’s a texture given or not, and it works, however:
Roblox outputs: Texture is not a valid member of Part "Workspace.Model.CampHat.Handle"
So now my main issue is finding the Handle of the accessory, does anyone have any idea as to how I can do that?