Hello,
So, the first button works and properly clones the models to the NPC, however, the second button clones to the NPC as well, but the position isn't moved to the NPC UpperTorso position. Any ideas on how to fix this? Thank you, for your time.
Respectfully,
sparkevin
local ShirtBttn1 = sp:WaitForChild('Shirt1Button')
local ShirtBttn2 = sp:WaitForChild('Shirt2Button')
ShirtBttn1.MouseButton1Down:Connect(function()
if workspace.CurrentCamera:findFirstChild("CustomCharacter") ~= nil and game.ReplicatedStorage:findFirstChild("Chest1") == nil then
local g = game.ReplicatedStorage.Shirts.Chest1:clone()
local d = game.Workspace.CurrentCamera:FindFirstChild("CustomCharacter")
g.Parent = d
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or "Union" 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 = d["UpperTorso"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, -0.5, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
if h[i].className == "Part" or "Union" then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end)
ShirtBttn2.MouseButton1Down:Connect(function()
if workspace.CurrentCamera:findFirstChild("CustomCharacter") ~= nil and game.ReplicatedStorage:findFirstChild("Chest2") == nil then
local g = game.ReplicatedStorage.Shirts.Chest2:clone()
local d = game.Workspace.CurrentCamera:FindFirstChild("CustomCharacter")
g.Parent = d
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or "Union" 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 = d["UpperTorso"]
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, -0.5, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
if h[i].className == "Part" or "Union" then
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
end)
