How to weld a part to a player with a script properly

I’ve been trying to make a morph and i’ve been using weldconstraints to weld the parts to the player, and using CFrame and position to regulate the part’s position to the current limb position, but that hasn’t been working at all (not positioned correctly, going too far away from the player or making the player fly). So i was wondering, how can i weld it properly to the character?

2 Likes

First of all, when welding parts to a player, all part should have CanCollide off (if possible).
Is the Part not welding correctly because of player movement, a script bug, or something else?

3 Likes

CanCollide is off on all of the parts that i weld,and i am not aware of any player movement related issues. When i set the morph limbs positions with CFrame, the player starts flying as if they’re suffering that half-in-the-ground glitch until i delete all the parts. Everything else works fine when i use collision though, but it’s rather busty.

My main issue is with the Head, as it is a model, setting the PrimaryPart CFrame to the player’s head CFrame makes it offset way too far, so i was hoping there was an alternative method to attaching a part to a player rather than using WeldConstraints.

1 Like

Here is the script, though. It’s a serverscript.

local Players = game.Players

local MorphButton = script.Parent

local Morph = MorphButton.Parent

local LeftArm = Morph:FindFirstChild("LeftArm")
local LeftLeg = Morph:FindFirstChild("LeftLeg")
local Torso = Morph:FindFirstChild("Torso")
local RightLeg = Morph:FindFirstChild("RightLeg")
local RightArm = Morph:FindFirstChild("RightArm")
local Head = Morph:FindFirstChild("Head")

local Morphed = false

local MorphedPlayers = {}

MorphButton.Touched:Connect(function(otherPart)
	if otherPart.Parent:FindFirstChildOfClass("Humanoid") and table.find(MorphedPlayers,otherPart.Parent) == nil then
		local Player = Players:GetPlayerFromCharacter(otherPart.Parent)
		if Player.Name == otherPart.Parent.Name then
			
			Morphed = true
			task.spawn(function()
				wait(5)
				Morphed = false
			end)
			
			print("Player morphed!")
			table.insert(MorphedPlayers,otherPart.Parent)
			
			local PlayerLeftArm = otherPart.Parent:FindFirstChild("Left Arm")
			local PlayerLeftLeg = otherPart.Parent:FindFirstChild("Left Leg")
			local PlayerTorso = otherPart.Parent:FindFirstChild("Torso")
			local PlayerRightLeg = otherPart.Parent:FindFirstChild("Right Leg")
			local PlayerRightArm = otherPart.Parent:FindFirstChild("Right Arm")
			local PlayerHead = otherPart.Parent:FindFirstChild("Head")
			PlayerLeftArm.Anchored = true
			PlayerLeftLeg.Anchored = true
			PlayerTorso.Anchored = true
			PlayerRightLeg.Anchored = true
			PlayerRightArm.Anchored = true
			PlayerHead.Anchored = true
			wait(2)
			
			local LeftArmClone = LeftArm:Clone()
			local LeftArmWeld = Instance.new("WeldConstraint")
			LeftArmClone.Parent = PlayerLeftArm
			LeftArmWeld.Parent = LeftArmClone
			LeftArmWeld.Part0 = LeftArmClone
			LeftArmWeld.Part1 = PlayerLeftArm
			LeftArmClone.Anchored = false
			LeftArmClone.CFrame = PlayerLeftArm.CFrame
			LeftArmClone.Name = Morph.Name.."LeftArm"
			LeftArmClone.CanCollide = false
			LeftArmClone.Orientation = PlayerLeftArm.Orientation
			
			local LeftLegClone = LeftLeg:Clone()
			local LeftLegWeld = Instance.new("WeldConstraint")
			LeftLegClone.Parent = PlayerLeftLeg
			LeftLegWeld.Parent = LeftLegClone
			LeftLegWeld.Part0 = LeftLegClone
			LeftLegWeld.Part1 = PlayerLeftLeg
			LeftLegClone.Anchored = false
			LeftLegClone.CFrame = PlayerLeftLeg.CFrame
			LeftLegClone.Name = Morph.Name.."LeftLeg"
			LeftArmClone.CanCollide = false
			LeftLegClone.Orientation = PlayerLeftLeg.Orientation
			
			local TorsoClone = Torso:Clone()
			local TorsoWeld = Instance.new("WeldConstraint")
			TorsoClone.Parent = PlayerTorso
			TorsoWeld.Parent = TorsoClone
			TorsoWeld.Part0 = TorsoClone
			TorsoWeld.Part1 = PlayerTorso
			TorsoClone.Anchored = false
			TorsoClone.CFrame = PlayerTorso.CFrame
			TorsoClone.Name = Morph.Name.."Torso"
			TorsoClone.CanCollide = false
			TorsoClone.Orientation = PlayerTorso.Orientation
			
			local RightLegClone = RightLeg:Clone()
			local RightLegWeld = Instance.new("WeldConstraint")
			RightLegClone.Parent = PlayerRightLeg
			RightLegWeld.Parent = RightLegClone
			RightLegWeld.Part0 = RightLegClone
			RightLegWeld.Part1 = PlayerRightLeg
			RightLegClone.Anchored = false
			RightLegClone.CFrame = PlayerRightLeg.CFrame
			RightLegClone.Name = Morph.Name.."RightLeg"
			RightLegClone.CanCollide = false
			RightLegClone.Orientation = PlayerRightLeg.Orientation
			
			local RightArmClone = RightArm:Clone()
			local RightArmWeld = Instance.new("WeldConstraint")
			RightArmClone.Parent = PlayerRightArm
			RightArmWeld.Parent = RightArmClone
			RightArmWeld.Part0 = RightArmClone
			RightArmWeld.Part1 = PlayerRightArm
			RightArmClone.Anchored = false
			RightArmClone.CFrame = PlayerRightArm.CFrame
			RightArmClone.Name = Morph.Name.."RightArm"
			RightArmClone.CanCollide = false
			RightArmClone.Orientation = PlayerRightArm.Orientation
			
			local HeadClone = Head:Clone()
			local HeadWeld = Instance.new("WeldConstraint")
			HeadClone.Parent = PlayerHead
			HeadWeld.Parent = HeadClone
			HeadWeld.Part0 = HeadClone.PrimaryPart
			HeadWeld.Part1 = PlayerHead
			HeadClone.PrimaryPart.Anchored = false
			HeadClone.PrimaryPart.CFrame = PlayerHead.CFrame
			HeadClone.Name = Morph.Name.."Head"
			HeadClone.PrimaryPart.CanCollide = false
			HeadClone.PrimaryPart.Orientation = PlayerHead.Orientation
			
			PlayerLeftArm.Anchored = false
			PlayerLeftLeg.Anchored = false
			PlayerTorso.Anchored = false
			PlayerRightLeg.Anchored = false
			PlayerRightArm.Anchored = false
			PlayerHead.Anchored = false
			
		for i, Part in pairs(otherPart.Parent:GetChildren()) do
				if Part:IsA("Part") then
					Part.Transparency = 1
				elseif Part:IsA("Accessory") then
					local AccessoryPart = Part:FindFirstChild("Handle")
					AccessoryPart.Transparency = 1
				end
				
			end
		end
	end
end)
1 Like

Tried using the qperfection weld script?

1 Like

What is that, if i may ask?
char

Quick note, the actual issue here is that the player glitches out and the arms and legs are placed incorrectly. Just made a few edits to the script now, and fixed it from when it used to spazz out.
(look at script above for edit)

its like an auto weld tool script

1 Like

maybe use tool grip editor plugin for that?

1 Like

How would i go about using that correctly to weld morph parts to the player? Could you elaborate?