Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by
Yeevivor4 155
8 years ago

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

Log in to vote
1
Answered by 8 years ago

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
Ad

Answer this question