Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you put the same clothes on someone if they die and they respawn again?

Hi, what I'm trying to do here is put some clothes on someone when they respawn. **The Problem is that after they die, the person will go back to originally what they were wearing. ** I don't want that to happen and if anyone can help me, I will be really grateful.

function PutClothesOn()

Player = game.Players.LocalPlayer

local shirt = Player.Character:FindFirstChild("Shirt")
					local pants= Player.Character:FindFirstChild("Pants")
						repeat wait() until Player.Character
							shirt.ShirtTemplate =  "http://www.roblox.com/asset/?id=243262382"
							pants.PantsTemplate = "http://www.roblox.com/asset/?id=233071264"
	
function onPlayerRespawned(newPlayer)
		local humanoid =  newPlayer.Character.Humanoid
		humanoid.Respawned:connect(PutClothesOn)

1 answer

✓ Accepted answer

Instead of using a Local script to do this why don't you use a Regular Script?

game.Players.PlayerAdded:connect(function(Player)--Fires when the Player Joins the game.
Player.CharacterAdded:connect(function(Character)--Fires when the Player's Character spawns or respawns.
	local Shirt = Character:WaitForChild("Shirt")--This wait for the Shirt to load so we don't cause an error later on.
	local Pants = Character:WaitForChild("Pants")--Same goes for this.
		Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=243262382"
		Pants.PantsTemplate = "http://www.roblox.com/asset/?id=233071264"
	end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.