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.