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

Changing Clothing at the start of the game?

Asked by 8 years ago
Edited 8 years ago

I need to know how to make a script that changes the persons normal clothing into the clothing like gladiator armor on them?

1 answer

Log in to vote
0
Answered by
Klamman 220 Moderation Voter
8 years ago
Edited 8 years ago

If you want to do this the easiest thing to do is to use the PlayerAdded event.

game.Players.PlayerAdded:connect(function(player) 

Next, check to see if the player has a shirt or pants

game.Players.PlayerAdded:connect(function(player)
    if player:FindFirstChild("Shirt") then
        player:FindFirstChild("Shirt").ShirtTemplate = "[insert shirt asset here]"
    end
    if player:FindFirstChild("Pants") then
        player:FindFirstChild("Pants").PantsTemplate = "[insert pants asset here]"
end

The if statements will only execute if the player is wearing a shirt for the first, and pants for the second.

The next step would be to insert new shirt and pants objects if they do not have a shirt or pants, or if they do to set their shirt and pants' asset IDs to that of the clothing you wish to have the player wear.

The final script, then will look like this

game.Players.PlayerAdded:connect(function(player)
    if player:FindFirstChild("Shirt") then
        player:FindFirstChild("Shirt").ShirtTemplate = "[insert shirt asset here]"
    else
        local shirt = Instance.new("Shirt")
        shirt.ShirtTemplate = "[insert shirt asset here]"
        shirt.Parent = player
    end
    if player:FindFirstChild("Pants") then
        player:FindFirstChild("Pants").PantsTemplate = "[insert pants asset here]"
    else
        local pants = Instance.new("Pants")
        pants.PantsTemplate = "[insert pants asset here]"
        pants.Parent = player
    end
end

Hope this helps!

0
Thanks man that helps alot CaptainRoblox281 15 — 8y
0
it doesn't seem to be working CaptainRoblox281 15 — 8y
0
@CaptainRoblox281, what error are you getting? Klamman 220 — 8y
0
Been trying to figure this one out for a while. Thanks for the help Klamman! Nik1080 24 — 8y
Ad

Answer this question