Suit giver/remover not working [NOT SOLVED]

I want to make a suit giver that returns the player to their normal avatar once they finish using the suit.

My current issue is that it doesn’t seem to run the “if” statement after taking out the suit.

I have attempted to re-script and put print statements in to check where the script is getting. When “SuitTaken” is true (suit is taken) then it connects the function but does not enter the “if” statement (where the code to remove the suit is).

Video:

Code:

local pantsId = script.Parent.Parent.Coathanger.Pants.PantsTemplate
local shirtId = script.Parent.Parent.Coathanger.Shirt.ShirtTemplate
local cPart = script.Parent
local cDetector = script.Parent.ProximityPrompt

local PlayerShirtID = "rbxassetid://0"
local PlayerPantsID = "rbxassetid://0"

local function Giver(player)
	
	if script.Parent.SuitTaken.Value == false then
		
		print("entered if statement")
		
		local foundShirt = player.Character:FindFirstChild("Shirt")
		
		if not foundShirt then

			local newShirt = Instance.new("Shirt", player.Character)
			newShirt.Name = "Shirt"

		elseif foundShirt then

			PlayerShirtID = player.Character.Shirt.ShirtTemplate
			player.Character.Shirt:Remove()
			local newShirt = Instance.new("Shirt", player.Character)
			newShirt.Name = "Shirt"
			script.Parent.SuitTaken.Value = true

			local foundPants = player.Character:FindFirstChild("Pants")

			if not foundPants then

				local newPants = Instance.new("Pants", player.Character)
				newPants.Name = "Pants"

			elseif foundPants then

				PlayerPantsID = player.Character.Pants.PantsTemplate
				player.Character.Pants:Remove()
				local newPants = Instance.new("Pants", player.Character)
				newPants.Name = "Pants"

			end

			player.Character.Shirt.ShirtTemplate = shirtId
			player.Character.Pants.PantsTemplate = pantsId
			print(PlayerShirtID)
			print(PlayerPantsID)
		
	elseif script.Parent.SuitTaken.Value == true then
		
			print("executing p2")
			player.Character.Shirt:Remove()
			local newShirt = Instance.new("Shirt", player.Character)
			newShirt.Name = "Shirt"
			player.Character.Shirt.ShirtTemplate = PlayerShirtID

			player.Character.Pants:Remove()
			local newPants = Instance.new("Pants", player.Character)
			newPants.Name = "Pants"
			player.Character.Pants.PantsTemplate = PlayerPantsID

			script.Parent.SuitTaken.Value = false

			print(PlayerShirtID)
			print(PlayerPantsID)
			print(script.Parent.SuitTaken.Value)
			
		end
		
		print("exited if statement")
		
	end
	
end

cDetector.Triggered:Connect(Giver)

Output:

  14:10:46.157  :: Adonis :: Loading Version: 259 Complete; Required by Loader version: 259  -  Server
  14:11:16.004  :: Adonis :: Changed lenovo17101s team to PTIA  -  Server
  14:12:14.490  Video recording started  -  Studio
  14:12:16.009  entered if statement  -  Server - Main:13
  14:12:16.010  http://www.roblox.com/asset/?id=14190975975  -  Server - Main:48
  14:12:16.010  http://www.roblox.com/asset/?id=398633811  -  Server - Main:49
  14:12:16.010  exited if statement  -  Server - Main:73
  14:12:34.394  Video recording stopped  -  Studio
  14:12:41.137  :: Adonis :: Beginning Adonis cleanup & shutdown process...  -  Server
  14:12:41.138  :: Adonis :: Unloading complete  -  Server
  14:12:41.094  Disconnect from ::ffff:127.0.0.1|64726  -  Studio

Any help would be greatly appreciated!

1 Like

Store the original character model in a folder, and set it to the character when he activates the prompt again.

How would I do that? (I’m not the best scripter and haven’t done something like that ever)

1 Like

You know how to change the players clothes, maybe store the asset ids of the shirt and pants, and remove any accessories you add to the character, and set the players clothes to that

1 Like

Is that not what the script in the post should be doing? I don’t know where I went wrong with it or why it doesn’t remove the suit (change the players clothes back). To me it looks like it should do that.

Part of the script that should handle that:

			player.Character.Shirt:Remove()
			local newShirt = Instance.new("Shirt", player.Character)
			newShirt.Name = "Shirt"
			player.Character.Shirt.ShirtTemplate = PlayerShirtID

			player.Character.Pants:Remove()
			local newPants = Instance.new("Pants", player.Character)
			newPants.Name = "Pants"
			player.Character.Pants.PantsTemplate = PlayerPantsID

Should I not remove and re-create the shirt and pants (just change the ID)?