You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I have multiple buttons that players can step on which changes their clothes and I want to make a button that if a player touches, it then resets their clothes to what their avatar was wearing.
What is the issue? Include screenshots / videos if possible!
I don’t know how to do it, I have tried many things.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried YT and Devforum
local originalshirt = 0
local originalpants = 0
local ps = game:GetService("Players")
ps.PlayerAdded:Connect(function(player))
local attachclothes = player.CharacterLoaded:Connect(function()
originalshirt = player.Character:FindFirstChild("Shirt").AssetID -- forgot what its called to get the id
originalpants = player.Character:FindFirstChild("Pants").AssetID -- forgot what its called to get the id
end)
-- disconnect the function i dont remember if the player has an event for leaving but you can figure it out yourself
end)
it’s a start to your solution, it gets the players original clothes, you can then do whatever you want with this information. giving you the straight answer is no way to learn
You can do a folder in ServerStorage or whatever, and if a player joins and character is loaded, you can clone the HumanoidDescription from the Humanoid and name it to the name of the Player. If you want to take everything, just do ApplyDescription(), if not, copy the ids of it by
(Edit as you will, might not work perfectly with your game)
local Players = game:GetService("Players")
local Part = "Path"
Part.Touched:Connect(function(Hit) -- Touched connection to detect whenever a character touches the part
local Character = Hit.Parent.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
assert(Humanoid, "Couldn't find Humanoid")
local Player = Players:GetPlayerFromCharacter(Character)
local Description = Players:GetHumanoidDescriptionFromUserId(Player.UserId) -- Get original HumanoidDescription
local CharacterDescription = Humanoid:GetAppliedDescription() -- Get the applied description from Humanoid
if Description and CharacterDescription then -- Applies the original clothes to the current HumanoidDescription
CharacterDescription.Shirt = Description.Shirt
CharacterDescription.Pants = Description.Pants
Humanoid:ApplyDescription(CharacterDescription)
end
end)
I think all you gotta do is just copy the ids of the shirts when they join and store them in a folder. When the player touches the part their clothing id is changed to the ids stored in the folder
I would assume its like making a leaderstats like in a simulator game.
game.Players.PlayerAdded:Connect(function(plr) -- Player joined
plr.CharacterAdded:Connect(function(char) -- get character
local folder = Instance.new("Folder", plr) -- make folder
folder.Name = "OriginalClothes" -- name folder
char:WaitForChild("Pants"):Clone().Parent = folder --clone pants to folder
char:WaitForChild("Shirt"):Clone().Parent = folder -- clone shirt to folder
end)
end)
This script clones the clothes of the player when they first joined. So in the script when they touch the part just change the clothes they have to the one in the folder.