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

How do i make a player's clothes appear when they died/respawned?

Asked by
oSyM8V3N 429 Moderation Voter
6 years ago

I have a script where it morphs the players shirt, and pants, but when they die, it disappear.

This is the script :

game.Workspace.ChildAdded:connect(function(player)
    local name = player.Name
    local playerinplayers = game.Players:FindFirstChild(player.Name)
    if playerinplayers ~= nil then
        playerinplayers.CanLoadCharacterAppearance = false
        player.Head.face.Texture = "rbxgameasset://Images/face1"
        player.Head.Transparency = 0
        local bodycolors = Instance.new("BodyColors", player) 
        bodycolors.TorsoColor = BrickColor.new("Pastel yellow")
        bodycolors.RightArmColor = BrickColor.new("Pastel yellow")
        bodycolors.LeftArmColor = BrickColor.new("Pastel yellow")
        bodycolors.HeadColor = BrickColor.new("Pastel yellow")
        bodycolors.LeftLegColor = BrickColor.new("Pastel yellow")
        bodycolors.RightLegColor = BrickColor.new("Pastel yellow")
        wait(2)
        local shirt = Instance.new("Shirt", player)
        shirt.ShirtTemplate = "rbxgameasset://Images/GokuShirt1"
        local pants = Instance.new("Pants", player)
        pants.PantsTemplate = "rbxgameasset://Images/GokuPants4"
        script.Disabled = true
    end
end)
0
It should work. Although, I suggest using the `PlayerAdded` and `CharacterAdded` events. Goulstem 8144 — 6y
0
I should warn you that there is a prohibition against allowing characters to be nude in games. This may be moderated. XAXA 1569 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Instead of using workspace.ChildAdded, use Player.CharacterAdded. http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded

You'll want to attach this event to each player upon joining:

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(character)
        -- your code here
        -- the player's character model is now in the "character" variable
    end
end
0
Thanks, it worked! :) oSyM8V3N 429 — 6y
0
Glad I could help! BreadyToCrumble 121 — 6y
Ad

Answer this question