Hey there,
I am currently working on a clothing loadout system for my game. I made a simple UI where players open it and different clothing appears on humanoids for display. They click a button and those clothes get applied to their characters. I am having some problems with this.
First, the display function to show the clothing on the humanoid does not work and looks like the following.
(Client) Code:
local function createDummyDisplay(viewportFrame, shirtId, pantsId)
local camera = Instance.new("Camera")
camera.Parent = viewportFrame
viewportFrame.CurrentCamera = camera
local displayDummy = displayDummy:Clone()
displayDummy.Parent = viewportFrame
displayDummy.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. shirtId
displayDummy.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=" .. pantsId
end
Result:
Second, the code to apply the clothing to the player’s character. The following code segment is what I am using and when this runs, the player appears naked with no clothing on.
(Server) Code:
applyUniform.OnServerEvent:Connect(function(player, shirtId, pantsId)
local character = player.Character
if character then
local shirt = character:FindFirstChildOfClass("Shirt")
local pants = character:FindFirstChildOfClass("Pants")
if not shirt then
shirt = Instance.new("Shirt")
shirt.Parent = character
end
if not pants then
pants = Instance.new("Pants")
pants.Parent = character
end
shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. shirtId
pants.PantsTemplate = "http://www.roblox.com/asset/?id=" .. pantsId
end
end)
Please let me know if you know any fixes to this! Any help is much appreciated, thanks!