So I am making a custom tool system for my game. I have a part in every tool called “BodyFence”. BodyFence is the Part1 for the Motor6D that I am animating it with. However, since every tool has a part named BodyFence, the animations are getting confused. For example, the bandage that you see on this axe is actually meant to be on my belt, but since the axe’s animation is playing second, it’s taking all BodyFences in the player and animating it with the current animation.
Unfortunately, I’m really not sure what is the whole purpose of this set behaviour? Can you please explain what is the goal here and how are these two animations connected between each other? How are they managed? Obviously, you don’t have to disclose any details here, only the most relevant parts and most basic fundamentals of your script.
Is it that you are trying to hold an axe and add a bandage to the waist, when the tool is equipped? Do you have one action set, like: on tool activation, play bandage animation and then equip the axe while playing another animation? The end bandage position doesn’t necessary have to be a looped animation, but rather an attached part.
Sorry I didn’t really include any pieces of my script as I don’t really know if this is so much a programming issue as it is with the animation editor. In the animation editor, when you animate say the left arm for example, the keyframe will be under UpperLeftArm or LowerLeftArm. For me, the keyframe was under the part of the tool called BodyFence. But since there’s multiple tools in the player’s character hierarchy that both have the name BodyFence it is getting confused.
What I was initially trying to achieve was having separate and multiple ongoing animation tracks with different tools. So you could have a bandage on your waist and an axe on your hip, but if you wanted to equip the axe then you could only stop the axe-on-hip animation to play the axe-in-hand animation.
I never really thought of making it an attached part though! That’s definitely something I should have thought about! I’m not really sure how I would attach it in a certain position though.
Oh, I get it now. I don’t exactly know how to fix the parts name confusion other than by simply changing the names to different ones manually (or maybe by playing with hierarchy and priority). However, how to attach parts to player? Well, you can weld them. There is possibly a different approach, but you can do something like:
local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local function AttachBandage()
local bandage = -- path (probably clone it)
local newWeld = Instance.new('Weld', bandage)
newWeld.Part0 = bandage
newWeld.Part1 = character:FindFirstChild('LowerTorso')
newWeld.C0 = -- exact position on torso
end
I see. Please excuse me for the late reply. C0 and C1 are two properties of JointInstance. While Roblox Dev Wiki explains everything in a very brief, efficient and ordered way, it is sometimes beginner not so friendly and sometimes hard to understand (I had to read this quite a couple of times to understand it myself). They are actually represent offsets, that being two CFrames: C0 is property of Part0 and C1 of Part1. So, create a weld, parent it to bandage, determine Part0 (one end) and Part1 (other end) and modify the offsets.
This is a nice and valuable post by @Isocortex , in relation to how player can attach a flag to their back in capture the flag kind of game (in a way that attachment is visible to other players).
Finally, Roblox Dev Wiki proposes using WeldConstraints as a newer alternative to Welds. That is a solid approach, not very different, but be aware of possible exploits while using Constraints with unanchored parts (exploiters can manipulate tools to some extent either way).
Now good luck with your projects and set some sanity checks for them silly exploiters