Applying layered clothing to NPC via client

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

As funny as it is: I script in single lines, I didn’t want to waste much time to indent it since I was also exploding in joy I had found the solution.

If you want I can indent the code and apply proper comments to help people out. (Sorry for the delay on the answer, I don’t really check the forums consistently)

I actually just felt obligated to do that now, so here it is:

--Place this in a LocalScript inside of ReplicatedFirst.
repeat wait() until game:IsLoaded()
--^ Simple code just to wait the game finish loading.
local pl,sc,wm,vw,vwc=game.Players.LocalPlayer,Instance.new("ScreenGui"),Instance.new("WorldModel"),Instance.new("ViewportFrame"),Instance.new("Camera")
--^ This line of code isn't that relevant, it is there to create the necessary GUI elements just to showcase the solution and set up some other variables.
sc.Parent = pl:WaitForChild("PlayerGui")
vw.Size = UDim2.new(0.5,0,0.5,0)
vw.CurrentCamera = vwc
vw.Parent = sc
wm.Parent = vw
vwc.Parent = vw
--^ This small section basically sets up a test GUI, a viewport and a camera for the test.
local ch = pl.Character or pl.CharacterAdded:Wait()
repeat wait() until (ch:FindFirstChildWhichIsA("Humanoid",true) and ch:FindFirstChildWhichIsA("HumanoidDescription",true))
--^ These two lines of code waits for your character to spawn, puts it in a variable and checks if the game already properly loaded it in.
--Once it does that it basically grabs it's humanoid description to build a rig for the test. (Requiring you to actually be wearing a layered clothing for this test!)
local vwm = game.Players:CreateHumanoidModelFromDescription(ch:FindFirstChildWhichIsA("HumanoidDescription",true),ch:FindFirstChildWhichIsA("Humanoid").RigType)
--^ Rig creating line of code. (Yeah.)
--VVV SOLUTION VVV
game:GetService("ContentProvider"):PreloadAsync({vwm})
--^^^ SOLUTION ^^^
--This line of code gets the ContentProvider service and preloads the model.
--By preloading the rig's model, it basically loads all data assigned to it in your client even before being placed into the world.
--I don't know what is the cause of the issue, but it may have something to do with how cage-meshes are dealt with, maybe (Take the next sentence with a grain of salt.) they require to be ran in the physics simulation to load in properly, in which a GUI lacks that.
--And so (Also take this with a grain of salt.) preloading probably runs it through the physics simulation, allowing it to load-in properly.
--DISCLAIMER THAT THIS IS AN ASSUMPTION LITERALLY MADE BY SOMEONE WHO IS *NOT* A ROBLOX ENGINEER. (Third time I'll say this, take those sentences with a grain of salt.)
vwm:SetPrimaryPartCFrame(CFrame.new(0,vwm:FindFirstChildWhichIsA("Humanoid").HipHeight+vwm.PrimaryPart.Size.Y/2,0))
--^ Sets the rig's position in the viewmodel in a way it's legs doesn't stick through the floor.
vwm.Name = "ViewmodelRig"
vwm.Parent = wm
vwc.CFrame = CFrame.new(Vector3.new(0,5,-5),vwm.PrimaryPart.Position+Vector3.new(0,1,0))
--^ Places the rig into the viewport and sets up the camera via a very simple CFrame operation.
5 Likes