Hello, I have some morphs and there are scripts, they apply when you touch a brick, but I want the script to be changed so you will wear it automatically when you join a certain team, here’s the script.
script.Parent.Touched:Connect(function(hit)
wait(2)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)
if player.Team == game.Teams["Mobile Task Force"] then
if player:GetRankInGroup(7656235) >= 10 then
local g = script.Parent.Parent.HelmetCOM:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Head
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
if h[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
end
end)
Instead of using the part.Touched you can try modifying your script to use Player.CharacterAdded. Then adding the morph to them when they spawn on their respective team.
That’s too complicated for me, since I am not very good with scripting, there are codes like “g.Parent = hit.Parent” I don’t know how to change these, how to get the characters head and so on.
Below you will find a Model, which has an R6 and R15 version depending on which you use and it has an instruction too for a better understanding.
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local char = c
local player = p
if player.Team == game.Teams["Combative Forces"] then -- Change to your team you want this morph.
if player:GetRankInGroup(7656235) == 6 then -- Change to your group, if you don't want it to be group bound, remove this line and an end.
local g = script.Parent.Parent.Chest:clone() -- Rename Chest to the part you use for your Bodypart.
g.Parent = char
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = char.Torso -- Rename Torso to the Bodypart, can be Torso, Head, char["Right Leg"] or char["Left Leg"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local d = char:GetChildren()
local h = g:GetChildren()
for i = 1, # h do
if h[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "WedgePart" or C[i].className == "MeshPart" then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end
end)
end)