I'm trying to create a script that automatically changes the player's appearance on spawn.
This is my code so far for changing the shirt:
wait(5) local playerModel = game.Players.LocalPlayer.Character local shirt = playerModel:FindFirstChild("Shirt") if shirt then shirt:Destroy() end local newshirt = Instance.new("Shirt") newshirt.Name = "Shirt" newshirt.ShirtTemplate = "http://www.roblox.com/asset/?id=144076358" newshirt.Parent = playerModel
Except that this doesn't work. The old shirt is deleted and the new shirt is placed successfully in the player model, but the new shirt doesn't show up. The player just has no shirt.
I have also tried the alternative
wait(5) local player = game.Players.LocalPlayer local playerModel = player.Character player:ClearCharacterAppearance() local newshirt = Instance.new("Shirt") newshirt.Name = "Shirt" newshirt.ShirtTemplate = "http://www.roblox.com/asset/?id=144076358" newshirt.Parent = playerModel
This just leaves the player naked. The new shirt is still correctly placed in the model though!
I've spent hours trying different methods and researching this problem, like cloning the new shirt into the player model, but nothing has worked. I even found threads with this problem on this site, but those were old and also didn't work.
BTW, the wait() is just a placeholder for the code that waits until the player is fully loaded. I also own the shirt, so owning the shirt doesn't seem to be the problem.
Free model morphs do work, and their code seems to be almost the exact same, but for some reason mine doesn't work.
I don't know why yours wasn't working, I couldn't completely figure it out. However, there is an alternative solution, using InsertService.
However, the client can't load in assets, so you'd have to use a server script.
game:GetService('Players').PlayerAdded:Connect(function(plr) -- playerAdded event plr.CharacterAdded:Connect(function(char) -- characterAdded event wait(1) -- necessary as character finished loading after clearcharacterappearance so it didn't clear the character's appearance plr:ClearCharacterAppearance() local assetId = 144076358-- Id of the shirt you want local ok = game:GetService("InsertService"):LoadAsset(assetId) -- loads asset ok.Parent = char -- parent asset (shirt) ok.Shirt.Parent = char -- parent asset (shirt) ok:Destroy() -- Destroys left over model from insert service end) end)
If you NEED to do this from a LocalScript, then use a RemoteEvent. If you're not familiar with those, let me know, and good luck!