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

How do you give Players Custom Armour/Shirt on spawn?

Asked by 9 years ago

For instance: http://www.roblox.com/games/211563183/Relay In that thumbnail the Player's Are wearing a shirt & Pants although there not a template there custom made in studio how do you make that?

1 answer

Log in to vote
1
Answered by 9 years ago

Lets tackle your first problem about changing the Player's Shirt and Pants. Firstly, We'll need to decide the event we need to use to call the script. I suggest CharacterAdded event since it calls the script everytime a Player's Character respawns.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
    print(character.Name.." Has respawned!")
--Code 
    end)
end)

Now we have that done, we'll now need some way to access the Player's Character but luckily for us this is easier then is sound since we could use Parameters to access the Player's Character.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
    print(character.Name.." Has respawned!")
local Shirt =  character:FindFirstChild("Shirt")--This make sure if the Player's Character has a Shirt in the first place.
    if Shirt then 
    Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=60610281"-- Replace the Id with your desired Shirt Id

        end
    end)
end)

Since you know how to change the Player's Shirt, you can now do the same thing for the Pants or even T-shirt.

Now for attaching the "Armor" to the Player's Character. Only way you can do this is by welding the Armor to the Player's body part.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
local Armor  = Instance.new(Part, character)-- Using Instance we created a Part and parented it inside the Player's character.
local Armor.CFrame = character["Left Leg"].CFrame --For the welding process we'll need to Make the Part contact with the Player so the weld doesn't break.
local Weld =  Instance.new("Weld" , Armor)--We have created our weld and now we are Parenting it to the Armor
    Weld.Part1 = character["Left Leg"]--Connect the Part1 property of the Weld to the Player's left leg
    Weld.Part0 = Armor--Connect the Part0 property of the Weld to the Armor
    end)
end)

I'm not going to completely show you how Weld each Parts to each "body parts" since that would be pointless because you can use what you learnt to apply it to other body parts.

0
Or you could have done a loop for each part of the character's parts doing the same thing? DevChris 235 — 9y
Ad

Answer this question