I’ve never done welding before, I’m a beginner at it but I am trying to weld a part to my player’s feet because usually in the R15 rig type, there is a delay with kill bricks, which is caused because their hitboxes aren’t accurate.
My code:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local LegPart = Instance.new("Part")
LegPart.Parent = character
LegPart.Name = "LegPart"
LegPart.Anchored = false
LegPart.CanCollide = false
LegPart.Material = Enum.Material.SmoothPlastic
--LegPart.Transparency = 1
LegPart.Size = Vector3.new(2, 2, 1)
local legweld = Instance.new("Weld")
legweld.Parent = LegPart
legweld.Name = "LegPartWeld"
legweld.Part0 = character.HumanoidRootPart
legweld.Part1 = LegPart
legweld.C0 = CFrame.new(0,LegPart.Parent.LeftLowerLeg.Position.Z,0)
end)
end)
Basically the welding is supposed to go to the player’s left foot Z position, but
for some reason, it goes all the way to the top.
I feel like it is a problem with this part though, as when I made it
torsoweld.C0 = CFrame.new(0,LegPart.Parent.Position.Z,0)
if you have a solution, I would greatly appreciate it!
1 Like
Deathful
(deathful)
April 22, 2020, 3:14pm
2
You should parent things last due to performance and setting everything before using it.
Set the CFrame of the LegPart to the LeftLowerLeg of position.
Instead of using weld and going with the using inverse method, use WeldConstraints. WeldConstraints move with the part without breaking and make welding a lot easier.
Heres an example
Edit: Hopped onto my computer and fixed typos.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local LegPart = Instance.new("Part")
LegPart.Name = "LegPart"
LegPart.Anchored = false
LegPart.CanCollide = false
LegPart.Material = Enum.Material.SmoothPlastic
LegPart.Transparency = 0
LegPart.Size = Vector3.new(2, 2, 1)
LegPart.Parent = character
LegPart.CFrame = character.LeftLowerLeg.CFrame -- to adjust, do something like LegPart.CFrame = character.LeftLowerLeg.CFrame * CFrame.new (0,-3,0)
local legweld = Instance.new("WeldConstraint")
legweld.Name = "LegPartWeld"
legweld.Part0 = LegPart
legweld.Part1 = character.HumanoidRootPart
legweld.Parent = character.HumanoidRootPart
end)
end)
Hope it helps
2 Likes
It gives this error:
I believe this is because the part is literally falling out of the map and being destroyed right before the wled constraint is added, how can i fix this?
FIXED! It was just a problem because you made it “Part” when its supposed to be “Part1”.
1 Like
Deathful
(deathful)
April 22, 2020, 3:44pm
5
Was just about to tell you that I had a few typos. Im glad you got it fixed haha.
Also, dont forget to mark the solution. Ty
I will soon, but I am trying to make it right BELOW the torso, because the part is only at the left leg rn
Deathful
(deathful)
April 22, 2020, 4:08pm
7
CFrame to Humanoid Root Part instead then mutltiply with CFrame.new(vector3)
like this
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local LegPart = Instance.new("Part")
LegPart.Name = "LegPart"
LegPart.Anchored = false
LegPart.CanCollide = false
LegPart.Material = Enum.Material.SmoothPlastic
LegPart.Transparency = 0
LegPart.Size = Vector3.new(2, 2, 1)
LegPart.Parent = character
LegPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new (0,-2,0)
local legweld = Instance.new("WeldConstraint")
legweld.Name = "LegPartWeld"
legweld.Part0 = LegPart
legweld.Part1 = character.HumanoidRootPart
legweld.Parent = character.HumanoidRootPart
end)
end)