Hello everyone, I’ve been trying for about a week now to make a Team Armor script where let’s say if you were on TeamA, you would get a helmet attached to your head on spawn and if you were on teamB, you would get a vest.
I’m trying to make a SCP game and need help with making a script like that, if anyone has any ideas on how to make one, let me know.
I’m really stuck…
Create your helmet and vest accessory, put them in the replicated storage.
Create your 2 team
Then put this script in the StarterCharacterScript
local Character = script.Parent
local Player = game.Players:FindFirstChild(Character.Name)
if not Character:FindFirstChild("Helmet")and Player.TeamColor == BrickColor.new("Bright blue")then
local Clone = game.ReplicatedStorage.Helmet:Clone()
Clone.Parent = Character
elseif not Character:FindFirstChild("Vest")and Player.TeamColor == BrickColor.new("Bright red")then
local Clone = game.ReplicatedStorage.Vest:Clone()
Clone.Parent = Character
end
Also there is another way to do it, is to put this script in the serverScriptService then it will add the accessory when player respawn
local Players = game:GetService("Players")
local function onCharacterAdded(Character)
local Player = game.Players:FindFirstChild(Character.Name)
if not Character:FindFirstChild("Helmet")and Player.TeamColor == BrickColor.new("Bright blue")then
local Clone = game.ReplicatedStorage.Helmet:Clone()
Clone.Parent = Character
elseif not Character:FindFirstChild("Vest")and Player.TeamColor == BrickColor.new("Bright red")then
local Clone = game.ReplicatedStorage.Vest:Clone()
Clone.Parent = Character
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
R6 and R15 character has the same attachments for accessory.
Create a basic “Part”, Size 1,1,1, No anchored, No Can Collide, 1 Transparency.
Rename it “Handle” and place it in the accessory.
Create an “attachment” inside the “Handle” part, rename it “BodyFrontAttachment”.
So here when the accessory will be in a Character, the “Handle” part will be auto placed on the character torso
Now you can add your vest meshes / parts inside the “Handle” part, put them all no anchored and no can collide and correctly place them where is the Handle part in the workspace.
Weld all meshes / parts of your model to the “Handle” part by using this plugin: Weld - Roblox
To use the plugin, select the “Handle” part and all meshes / parts of your model and click the “Weld All” Button
Np for the help,
I’ve make a vest accessory for you with a free mesh if you want to check it (It is a bit to late xD) Vest.rbxl (55,7 Ko)
Accessory are really easy and fast to make when you know how it work ^^
To remove the wrong accessory if the player is in the other team
if not Character:FindFirstChild("Helmet")and Player.TeamColor == BrickColor.new("Bright blue")then
local Clone = game.ReplicatedStorage.Helmet:Clone()
Clone.Parent = Character
elseif not Character:FindFirstChild("Vest")and Player.TeamColor == BrickColor.new("Bright red")then
local Clone = game.ReplicatedStorage.Vest:Clone()
Clone.Parent = Character
end
if Character:FindFirstChild("Helmet")and not Player.TeamColor == BrickColor.new("Bright blue")then
Character.Helmet:Destroy()
elseif Character:FindFirstChild("Vest")and not Player.TeamColor == BrickColor.new("Bright red")then
Character.Vest:Destroy()
end
I got confused again, so the script works perfectly fine just I would like it so when you spawn on a team for example, when you join TeamA, it will remove all your hats THEN put of the custom hats. Very confused on how to make this
You can call RemoveAccessories prior to adding the vest and hat. This’ll remove all hats the player is wearing and then you can add your own hats to the character. Alternatively, use GetAccessories, go through the table it gives back and act based on the hat’s name.
Sorry but I don’t normally provide entire scripts because that’s not exactly the point of this category. It wouldn’t be helpful for the sake of learning and understanding what you’re doing which in turn can make future maintenance of your code more difficult.
That being said, in this case RemoveAccessories is just a simple call on the Humanoid. You simply need to have access to the Humanoid and then you can call RemoveAccessories on it. Do so before adding the hats. If you have access to the character, you can also get a reference to the character.
There is a code sample on the page you can reference.