I feel as if I am missing something, do I need to use C1? (even tho C1 didn't make a difference when I tested) I need help fixing up this script tho.
game:GetService("Players").PlayerAdded:connect(function(player) -- there is a part in game.Workspace named bigblock and you may replace :GetService("Players") with .Players if it makes your job easier to faster explain my script. player.CharacterAdded:connect(function(character) local part = game.Workspace:FindFirstChild("bigblock") part.Size = Vector3.new(8.8, 6.8, 8.2) part.Transparency = 0.75 part.CanCollide = false local weld = Instance.new("Weld") local torso = character:WaitForChild("Torso") weld.Part0 = torso weld.C0 = torso.CFrame:inverse() weld.Part1 = part weld.Parent = part end) end)
I use :inverse() so that the part may stick with the character's torso, the part is modified to have no cancollide, and it is not allowed to be anchored. Tell me if C1 is necessary for my script. Is the part not created properly or something? I even tried putting weld.Parent = part infront of the torso variable.
The rule of thumb when it comes to welds is:
part0.CFrame * C0 == part1.CFrame * C1
If you re-arange this then you can easily solve for what you want. Your part0 is torso and your part1 is the brick you're trying to attach. Let's say you want the part to be attached directly to the centre of the torso (you were kind of ambigious as to what you wanted). Let's also assume we aren't using C1 b/c it's an offset point from C0 and only usually needed when you're animating joints. As such we can assume C1 is an empty cframe value (CFrame.new()) meaning when we multiply it by other cframes it changes nothing thereby allowing us to eliminate it from the above equation:
part0.CFrame * C0 == part1.CFrame
From here we can rearrange to solve for C0:
C0 = part0.CFrame:inverse() * part1.CFrame;
However, because you want part0 and part1 to both have the same world CFrame the two cancel out and leave us with CFrame.new(). The above equation would work with any world cframes though so feel free to use it.