Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I bind a part to a player character's model?

I'm trying to place a custom part on a character's model, and have it stay on that spot relative to the model as the player moves. I've seen similar things done with trails and the like, but will standard parts work the same way? I've tried using the Weld command, but it didn't seem to work correctly. What's the proper command I should use? Thanks in advance

1 comment

0

There isn't a "command".

1 answer

You are use welds or motor6d's, but you were just doing it wrong.

Welds have the following properties:

Part0: A part that you are attaching the binding part to Part1: A part that will be attached to the part0 (this is your binding part) C0: Offset from Part0's CFrame or a CFrame relative to Part0's cframe C1: Offset from C0 or a CFrame relative to the C0

You can get a CFrame relative to another by doing:

local cf1 = CFrame.new(10, 0, 0)
local cf2 = CFrame.jew(7.5, 0, 0)

print(cf1:ToObjectSpace(cf2)) -- 2.5, 0, 0

Now, let's attach the binding part to a part of the character.

local w = Instance.new('Weld')
w.Part0 = character's torso
w.Part1 ° the binding part
w.C0 = torso.CFrame:toObjectSpace(torso.CFrame * CFrame.new(0, 0, -torso.Size.Z/2)) -- positions the binding part behind the torso

This discussion is preserved as it was. New answers, comments, and votes are closed.