So I have this code to weld a full body 'suit' to the player but currently it takes the existing suit out of the workspace & puts it on the player, I want it to instead make a clone of the original object(s) & then weld that to the player.

Here is the code:

function WeldEnable (x, y, z)
	if Prt1:FindFirstChild("weld") == nil then
		Prt1.CFrame = Prt0.CFrame * CFrame.new(x, y, z)
		weld = Instance.new("Weld")
		weld.Part0 = Prt0
		weld.C0 = Prt0.CFrame:Inverse()
		weld.Part1 = Prt1
		weld.C1 = Prt1.CFrame:Inverse()
		weld.Parent = Prt1
		weld.Parent.Anchored = false
		weld.Parent.CanCollide = false
	end
end

function LeftLegWeldEnable (x, y, z) 
	if Prt1:FindFirstChild("weld") == nil then
		Prt2 = Prt0.Parent:WaitForChild("LeftLowerLeg")
		Prt1.CFrame = Prt2.CFrame * CFrame.new(x, y, z)
		weld = Instance.new("Weld")
		weld.Part0 = Prt0
		weld.C0 = Prt0.CFrame:Inverse()
		weld.Part1 = Prt1
		weld.C1 = Prt1.CFrame:Inverse()
		weld.Parent = Prt1
		weld.Parent.Anchored = false
		weld.Parent.CanCollide = false
	end
end

function RightLegWeldEnable (x, y, z) 
	if Prt1:FindFirstChild("weld") == nil then
		Prt2 = Prt0.Parent:WaitForChild("RightLowerLeg")
		Prt1.CFrame = Prt2.CFrame * CFrame.new(x, y, z)
		weld = Instance.new("Weld")
		weld.Part0 = Prt0
		weld.C0 = Prt0.CFrame:Inverse()
		weld.Part1 = Prt1
		weld.C1 = Prt1.CFrame:Inverse()
		weld.Parent = Prt1
		weld.Parent.Anchored = false
		weld.Parent.CanCollide = false
	end
end





function FrameOn()
	Prt0 = Target:FindFirstChild("Head")
	Prt1 = Suit:FindFirstChild("Head")
	WeldEnable(0, 0, 0)
	Prt0 = Target:FindFirstChild("LeftLowerArm")
	Prt1 = Suit:FindFirstChild("LowerLeftArm")
	WeldEnable(0, -0.276, 0)
	Prt0 = Target:FindFirstChild("LeftLowerLeg") -- LowerLeg -0.0965
	Prt1 = Suit:FindFirstChild("LowerLeftLeg")
	WeldEnable(0, -0.2965, 0)
	Prt0 = Target:FindFirstChild("RightLowerArm")
	Prt1 = Suit:FindFirstChild("LowerRightArm")
	WeldEnable(0, -0.276, 0)
	Prt0 = Target:FindFirstChild("RightLowerLeg") -- LowerLeg
	Prt1 = Suit:FindFirstChild("LowerRightLeg")
	WeldEnable(0, -0.2965, 0)
	Prt0 = Target:FindFirstChild("LeftUpperArm")
	Prt1 = Suit:FindFirstChild("UpperLeftArm")
	WeldEnable(0, 0.1345, 0)
	Prt0 = Target:FindFirstChild("LeftUpperLeg")
	Prt1 = Suit:FindFirstChild("UpperLeftLeg")
	WeldEnable(0, -0.0965, 0)
	Prt0 = Target:FindFirstChild("RightUpperArm")
	Prt1 = Suit:FindFirstChild("UpperRightArm")
	WeldEnable(0, 0.1345, 0)
	Prt0 = Target:FindFirstChild("RightUpperLeg")
	Prt1 = Suit:FindFirstChild("UpperRightLeg")
	WeldEnable(0, -0.0965, 0)
	Prt0 = Target:FindFirstChild("UpperTorso")
	Prt1 = Suit:FindFirstChild("Torso")
	WeldEnable(0, -0.2, 0)
end

Suit = workspace.SuitFrame
Target = workspace:WaitForChild("CoolOlivie057")
FrameOn()

BTW 'SuitFrame' is the different parts I want to weld to the player grouped together & 'CoolOlivie057' is my username!

P.S sorry for what I at least think is messy code, I am new to roblox scripting & the code may be big but it works the way I want it to, well, except for the 'clone' thing.

4 comments

0

you just clone Prt1:FindFirstChild("weld") with local clonedprt = Prt1:FindFirstChild("weld") :Clone()

0

oh, wait the Prt1:FindFirstChild("weld") is just to check if the part is already welded so that it can't get welded twice

0

I was thinking maybe putting something like: newSuit = Suit:Clone() in the top of the FrameOn function but I don't know where to go from there.

0

Nvm I got it to work