Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix improper welding?

Asked by 8 years ago

Problem : I the script welds the torso part properly but the parts in the legs do not weld properly when i start the game, i cannot see the parts, no errors in output, I checked, and the parts are attached to my legs, but they're inside my legs for some reason.

script:

local button=script.Parent
local LeftLeg = game.ReplicatedStorage.Leather.LeftLegWeld.Piece:Clone()
local RightLeg = game.ReplicatedStorage.Leather.RightLegWeld.Piece:Clone()
local Torso = game.ReplicatedStorage.Leather.TorsoWeld.Union:Clone()
local Player = game.Players.LocalPlayer
local HeathBoost = 25

button.MouseButton1Down:connect(function()
    print("Attaching Armor")
    --Torso Attach--
local w = Instance.new("Weld")
w.Part0 = Torso 
w.Part1 = Player.Character.Torso 
w.Parent = Player.Character.Torso   
    --Right Leg Attach--    
local w2 = Instance.new("Weld")
w2.Part0 = RightLeg
w2.Part1 = Player.Character["Right Leg"]
w2.Parent = Player.Character["Right Leg"]       
    --Left Leg Attach--
local w3 = Instance.new("Weld")
w3.Part0 = LeftLeg 
w3.Part1 = Player.Character["Left Leg"]
w3.Parent = Player.Character["Left Leg"]    
    --Teleport Armor To Player --
    LeftLeg.Parent = Player.Character["Left Leg"]
    RightLeg.Parent = Player.Character["Right Leg"]
    Torso.Parent = Player.Character.Torso
print("Attached")
wait(.1)
print("Increasing Health")
Player.Character.Humanoid.MaxHealth = Player.Character.Humanoid.MaxHealth+ HeathBoost
Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth
end)

2 answers

Log in to vote
0
Answered by 8 years ago

The C0 property is missing. It determines the offset of the parts.

0
You should tell him how to fix it. TheDeadlyPanther 2460 — 8y
0
We don't know exactly how big his parts are and how he wants them attached. It's not something we *can* fix. LightningRoMan 100 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Like other answer mentioned, you didn't set the weld offset. By default, weld will stick the Part1 directly inside the Part0.

From your description it seems that you want to weld the part to be exactly where it was physically positioned. For that you need to find the relative CFrame, here is how it would look:

local w2 = Instance.new("Weld")
w2.Part0 = RightLeg
w2.Part1 = Player.Character["Right Leg"]

-- If you are familiar with vector math, this is similar to: endVector - startVector
-- Very similar logic behind CFrame, just done differently
w2.C0 = w2.Part0.CFrame:inverse() * w2.Part1.CFrame:inverse()

w2.Parent = Player.Character["Right Leg"]

Answer this question