I wrote a script that is supposed to change the character’s clothing when a button is pushed but instead of switching to the chosen outfits, the characters just become naked and no one wants that since this is a predominantly kids platform.
The script:
SuitUp.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Player.Character:FindFirstChild("Humanoid")
local OriginalShirt = Character.Shirt.ShirtTemplate
local OriginalPants = Character.Pants.PantsTemplate
for _,v in pairs(Character:GetChildren()) do
if v:IsA("Accessory") and not v.Handle:FindFirstChild("HairAttachment")then
v.Handle.Transparency = 1
end
end
Character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=3282533924"
Character.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=19843664501"
end)
Try changing the links to the templates like this: “rbxassetid://YOURIDHERE”. If that doesn’t works, try inserting a shirt instance and a pants instance in Replicated Storage, put their IDs, and when the button is clicked, change the parent of the shirt and pants. Also don’t forget to use Destroy() on the other shirt and pants instances, to make it not break.
But I want the script to remember the original shirt and pants id so that i can revert them in the suit down function. Which is a different function here:
SuitDown.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
for _,v in pairs(Character:GetChildren()) do
if v:IsA("Accessory")then
v.Handle.Transparency =0
end
end
end)
I even took the id and put it besides Catalog - Roblox and it said it doesn’t exist also you could put a folder and put a shirt and pants instance inside of the folder and set the ids when the players character is added inside of a server script. Like this.
game:GetService("Players").PlayerAdded:Connect(function(Player)
local newFolder = Instance.new("Folder")
newFolder.Name = "DefaultClothing"
newFolder.Parent = Player
local Shirt = Instance.new("Shirt")
local Pants = Instance.new("Pants")
Shirt.Parent = newFolder
Pants.Parent = newFolder
Player.CharacterAdded:Connect(function(Character)
Shirt.ShirtTemplate = Character.Shirt.ShirtTemplate
Pants.PantsTemplate = Character.Pants.PantsTemplate
end)
end)
Im a man btw. Also to get the template for the shirt just put a shirt instance in your game and get the shirt id and put it as the template that will give you the template id which you can use to give the character a shirt.
This works all great and dandy EXCEPT according to @octav20071 I’ll have to destroy the original instances but I want the script to remember the original clothing ids so that I can revert them in the suit down function which is a seperate function on its own.
Why would you have to destroy the original instances you can just change the shirt template and pants template of the shirt and pants inside of the character.