How to make a bone follow an attachment

Hi everyone! I’d like to create a script that moves a bone of a mesh along with a part, as if the bone were attached to the part. practically the bone will have to follow the part in real time. I think this needs some cframe math but I’m not good at scripting so I thought maybe some of you could help me. any help is appreciated, have a nice day!

Could create a CFrame Value then tween the CFrame Value to always match the part’s CFrame.

And for the bone you would update the CFrame of the bone every time the CFrame Value changes.

local CFrameValuebone = Instance.new(“CFrameValue”)
CFrameValuebone.Value = WhereItStarts.CFrame

CFrameValuebone :GetPropertyChangedSignal(“Value”):Connect(function()

end)


Another alternative is to just always tween the bone to the part.
Either one works. (CFrameValue works best with Models)

1 Like

i did this but it doesnt work :frowning:

local CFrameValuebone = Instance.new(“CFrameValue”)
CFrameValuebone.Value = script.Parent.CFrame
CFrameValuebone.Parent = script.Parent

CFrameValuebone:GetPropertyChangedSignal(“Value”):Connect(function()
local part = script.Parent.Parent.Parent.HumanoidRootPart[“1”]
part.WorldCFrame = CFrameValuebone.Value
end)

1 Like

I mean, GetPropertyChangedSignal() fires only when that property changes, so it won’t actually run since nothing is setting it here (or at least not in your snippet).

also for a value object like int,string,bool,cframe etc, you can use the Changed event to detect changes in value instead.

Also what is 1 in the humanoidrootpart, is that the bone?
why not:

local RunService = game:GetService("RunService")
local Part = script.Parent.Parent.Parent.HumanoidRootPart["1"]

RunService.Heartbeat:Connect(function(delta)
   Part.WorldCFrame = script.Parent.CFrame
end)

Now every frame it will set the part’s cframe to the parent’s cframe, I did this because you initially set the value of the cframevalue to the parent’s cframe so I just assumed that that’s what you want constantly.

Also can’t you just weld the bone or use any other attachments? I don’t use bones so I wouldn’t know…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.