I have some parts that change the players shirt & pants on touch. I’m trying to have another part that resets the player to their original shirt & pants without resetting the player.
I read about storing and restoring the values but I have no idea how to do this, or, maybe there is a simpler way?
1 Like
Before you change the shirt and pants for the first time, have the script save the asset ID number as a variable. Then, if the player touches another part, have the script change the asset ID back to the original.
This script saves the IDs of the player’s clothes as variables
![clothes variable code](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/8/3/6/836ae4ef646297692f2ecc534ba8d5782bc0c8a5.png)
1 Like
Thanks for the help. I’m new to scripting so I’m nut sure how this works. My current result is that the PC has not clothes rather than reverting to stored original clothes. Here’s what I did.
Script In ServerScriptService:
(I added “local” to remove errors, which is probably wrong
)
changeP = script.Parent
ResetP = game.Workspace.Reset
Cooldown = false
changeP.Touched:connect(function(p)
if Cooldown == false then
local Human = p.Parent:FindFirstChild("Humanoid")
if Human then
local OGshirt = Human.Parent.Shirt.ShirtTemplate
local OGpants = Human.Parent.Pants.PantsTemplate
print (OGshirt)
print (OGpants)
Cooldown = true
wait (2)
Cooldown = false
end
end
end)
Script in the Part that should reset player clothes to their original clothes:
local sound = script.Parent.Team
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
hit.Parent.Pants.PantsTemplate = "OGShirt"
hit.Parent.Shirt.ShirtTemplate = "OGpants"
sound:play()
wait(5)
end
end)
I also added a Model to the workspace, named it “Reset” and added Pants & Shirt inside the model… Wasn’t sure what I was doing, but the script pointed to “game.Workspace.Reset” so I thought I may need to put that in the workspace.
I would personally use one script that controls both parts. That way once you can reference OGshirt and OGpants between both Touched functions. Make sure to remove the local in front of both the OGshirt and OGpants variables so both functions can reference them.
Also, you put OGshirt and OGpants in quotes so that instead of putting the ID number in the templates. “OGpants” and “OGshirt” are literally put in the template instead of the correct ID numbers, causing no clothes to display. You should remove the quotes so that the variables can be used properly.
I managed to get a script that can change the players clothes and revert them back.
watch e.wmv (1.1 MB)
changeP = script.Parent ---- button that changes the players clothes
ResetP = game.Workspace.Reset --- button that resets player's clothes
Cooldown = false -- boolean that keeps firsr ontouched function from playing too quickly
changeP.Touched:connect(function(P)
if Cooldown == false then
local Human = P.Parent:FindFirstChild("Humanoid") --finds the humanoid
if Human then -- makes sure there is a humanoid
OGshirt = Human.Parent.Shirt.ShirtTemplate -- the value for the players shirt
OGpants = Human.Parent.Pants.PantsTemplate -- value for player's pants
print(OGshirt)
print(OGpants)
Human.Parent.Shirt.ShirtTemplate = ("placeholderInfo")-- put the IDs for the clothes that you want here
Human.Parent.Pants.PantsTemplate = ("placeholderInfo")
Cooldown = true
OriginalStored = true --bool that determines that IDs are stored as varibles
wait(2)
Cooldown = false
end
end
end)
ResetP.Touched:connect(function(P)
if OriginalStored == true then
local Humanoid = P.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Parent.Shirt.ShirtTemplate = OGshirt -- sets shirt to variable stored above
Humanoid.Parent.Pants.PantsTemplate = OGpants --sets pants to variable stored above
print("Original Clothes restored")
end
end
end)
Just change the (“placeholderInfo”) strings to the ID of the clothing that you want.
![object hierachryc lothes](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/1/5/6/156e9e02d9397c02d70c0eb8fe0d50363c8829dd.png)
I should have named references better and provided a picture of the explorer in the first post, sorry about that. Hopefully you understand the script and can get it working. If you get any errors or have any questions just let me know and I should be able to clear it up.
ResetP what I called the Reset button inside the script. If you have a part called “Reset” inside the workspace it will change the players clothes back when it is touched.
5 Likes
Thanks so much for the help! Works perfectly!
I commented out the shirt / pants changes in my case, as I basically wanted players to be able to set themselves to “neutral” with their own clothes vs. being on a specific team. And I changed the ResetP to ResetP = script.Parent.Parent.Reset and placed the Reset block in the root of the Map because I needed it to work in a map that I load in. I’m just mentioning these in case someone else needs these simple adjustments. Thanks again!!!
1 Like