Hello devs, I’ve made a script that when the character is loaded (and the player is on a certain team) it equips. However when I switch to another team & the character reloads: The morph stays on?
Can anyone help with this (I’m using one part of it as an example)?
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local char = c
local player = p
if player.Team == game.Teams["Lobby"] then -- Change to your team you want this morph.
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)