Applying layered clothing to NPC via client

I am working on making an in-game catalog. Currently, when the player tries on layered clothing, it applies correctly to the player but not the player’s clone in the viewport. I am not sure if this has to do with me applying it via the client or if there is something else I am doing wrong.

Video of current behavior: https://gyazo.com/746e588a4a4fa9373635a1a0acbf105b

1 Like

I’ve search a little bit and this was the only working result I could find.
I guess you’d need to clone the character’s model over to the viewport.

1 Like

Unfortunately, that did not work. Based on the date of that article, it is possible that they are referring to classic clothing (shirt, pants, t-shirt) not rendering, not layered clothing.

Hmmm, tomorrow once I get home I will try seeing how I could help you out.
But for now I suggest you to try wandering around the forum and also thinking on ideas yourself.
Altho if cloning the character did not work then I am not entirely sure what else could do the job, maybe try applying a HumanoidDescription with the layered clothing on the preview char, dunno, all I know is that layered clothing and viewport frames are very buggy lol.

Okay, there could MAYBE be a high chance that they do not have compatibility with layered clothing, which wouldn’t be surprising since ViewportFrames LACKS on several features, such as skyboxes, anti-aliasing, etc., so… /shrug

It has to be possible somehow, cause other games that have an in-game catalog (such as this one) have managed to do it.

Well, since I’m not on my computer rn I can only take blind guesses…
What if you try the catalog thing in-game?
By in-game I actually mean publishing the game and then running it from the ROBLOX website.
There are several weird bugs that only exists in Studio, like UserInputService not registering the “I” and “O” keys, outside of Studio they are registered just fine.

Sadly still doesn’t work, even in game.

This might sound weird but:
Try creating the model ON the server and then pass it through a remote to the client, then ask the client to put it in the Viewport
I don’t know why but this could be the case…
(To not actually need to develop the entire remote process to test it out, make a dummy with a random layered clothing, run the simulation, go to your client, and parent the model to the Viewport, check if the layered clothing breaks or not)

I just tried something similar to that with no success. When the player joined and their character was added I tried creating the fake character on the server, then parenting it to the viewport. Sadly, it still broke the clothing.

Well, well, well… This is gonna be quite annoying to solve, for sure.
What method you were using to display the character before running into the layered clothing issue?
Feel free to post a bit of the script here so I could try figuring out a workaround.

All I am doing is taking a blank R15 rig in a WorldModel and getting the humanoid description from the character, then applying it to the R15 rig.

Well, what if you try placing the rig DIRECTLY under the ViewportFrame, without utilizing the WorldModel?
I’ve seen lots of people utilize WorldModels for Viewports but I’ve personally never seen any difference between using it and not using it.
I hardly think the WorldModel is interfering on the layered clothing rendering, but we could always try removing it just to be sure it isn’t the issue.

1 Like

I will try that tomorrow, it is late and I have work in the morning.

1 Like

Fair enough, good night bro.
I will also try my best helping you out tomorrow!

1 Like

I GOT IT WORKING!

--Place this in a LocalScript inside of ReplicatedFirst.
repeat wait() until game:IsLoaded()
local pl,sc,wm,vw,vwc=game.Players.LocalPlayer,Instance.new("ScreenGui"),Instance.new("WorldModel"),Instance.new("ViewportFrame"),Instance.new("Camera") sc.Parent,vw.Size,vw.CurrentCamera,vw.Parent,wm.Parent,vwc.Parent=pl:WaitForChild("PlayerGui"),UDim2.new(0.5,0,0.5,0),vwc,sc,vw,vw
local ch=pl.Character or pl.CharacterAdded:Wait()
repeat wait() until (ch:FindFirstChildWhichIsA("Humanoid",true) and ch:FindFirstChildWhichIsA("HumanoidDescription",true))
local vwm=game.Players:CreateHumanoidModelFromDescription(ch:FindFirstChildWhichIsA("HumanoidDescription",true),ch:FindFirstChildWhichIsA("Humanoid").RigType)
game:GetService("ContentProvider"):PreloadAsync({vwm})
vwm:SetPrimaryPartCFrame(CFrame.new(0,vwm:FindFirstChildWhichIsA("Humanoid").HipHeight+vwm.PrimaryPart.Size.Y/2,0))
vwm.Name,vwm.Parent,vwc.CFrame="ViewmodelRig",wm,CFrame.new(Vector3.new(0,5,-5),vwm.PrimaryPart.Position+Vector3.new(0,1,0))

ALL WE HAD TO DO WAS PRE-LOAD THE MODEL USING THE CONTENT PROVIDER SERVICE!

2 Likes

Dude, clean up the code if you’re going to provide it as a solution.

2 Likes

You can clean it up yourself, it only takes a minute or two.

Great suggestion! I’m sure newer developers who may be experiencing the same issue seriously appreciate your open-minded advice.

The answer to the question is to preload the model using content provider service (as stated in the solution post), not the code provided. The code is simply an example of how to use it IN MY CASE. Anyone who comes along this post shouldn’t even need the code.

1 Like