Making Meshes Swappable for a Sword Tool

Hey there, I’m kinda stumped and need a little guidance or would possibly hire for help if you are willing.

I’m trying to make different tools for different sword fighting styles but allow the players to choose what swords they want to use with the different fighting styles.

The problem I’m having though, for example, I have just the BASIC sword tool and when I try to swap in a different mesh, the new mesh is nowhere near being in the correct position, as you can see in the attachment. Screen Shot 2021-08-11 at 6.00.33 PM|690x395

I have tried messing around with the GripForward, GripPos, GripRight, and GripUp values for an hour or so and cannot get the freakin’ thing to line up. And I have to do this for like 10 different swords :sweat_smile:

Any tips would be appreciated. I am a pretty experienced Roblox developer, but tools have never been a strong point of mine. I have a developer team that I’m working with to create a very cool horror/strategy game with a pretty in depth story, but don’t currently have anyone anywhere close to my level of programming that can help me with tools. If you would like to find out more about what I’m developing or would like to become a part of the team, let me know. Thanks!


Consider using this plugin.

1 Like

Thank you! I will try it out! Clonetrooper’s stuff has always been great.

1 Like

So, I thought I made a bunch of progress with the plugin you suggested. Everything seemed to be going smoothly. I made a module script containing tables of all the different grip positions that the sword script could access and position the grip positions according to the selected mesh.

Module script:

local Holder = {};

Holder.ClassicSword = {{0,0,-1.5},{-1,0,0},{0,1,0},{0,0,1},{0,0,1},{0,-1,0},{-1,0,0}};
Holder.ClassicLaser = {{0,-1.7,0},{0,0,-1},{1,0,0},{0,1,0},{0,1,0},{1,0,0},{0,0,1}};
Holder.ClassicEnergy = {{0,-1.7,0},{0,0,-1},{1,0,0},{0,1,0},{0,1,0},{1,0,0},{0,0,1}};
Holder.ClassicShattered = {{0,1.7,0},{0,0,-1},{-1,0,0},{0,-1,0},{0,-1,0},{-1,0,0},{0,0,1}};
Holder.ClassicCorrupted = {{-1.7,2,0},{-0.707,-0.707,0},{0,0,1},{0.707,-0.707,0},{0.707,-0.707,0},{0,0,1},{0.707,0.707,0}};
Holder.ClassicLight = {{0,0,-2.6},{1,0,0},{0,-1,0},{0,0,1},{0,0,1},{0,-1,0},{-1,0,0}};

return Holder;

Section of the sword script that modifies the grip positions:

function swordUp()

Tool.GripForward =["Classic"..choice][2][1],holder["Classic"..choice][2][2],holder["Classic"..choice][2][3]);
Tool.GripRight =["Classic"..choice][3][1],holder["Classic"..choice][3][2],holder["Classic"..choice][3][3]);
Tool.GripUp =["Classic"..choice][4][1],holder["Classic"..choice][4][2],holder["Classic"..choice][4][3]);


function swordOut()

Tool.GripForward =["Classic"..choice][5][1],holder["Classic"..choice][5][2],holder["Classic"..choice][5][3]);
Tool.GripRight =["Classic"..choice][6][1],holder["Classic"..choice][6][2],holder["Classic"..choice][6][3]);
Tool.GripUp =["Classic"..choice][7][1],holder["Classic"..choice][7][2],holder["Classic"..choice][7][3]);



function onEquipped()

Tool.GripPos =["Classic"..choice][1][1],holder["Classic"..choice][1][2],holder["Classic"..choice][1][3]);
Tool.GripForward =["Classic"..choice][2][1],holder["Classic"..choice][2][2],holder["Classic"..choice][2][3]);
Tool.GripRight =["Classic"..choice][3][1],holder["Classic"..choice][3][2],holder["Classic"..choice][3][3]);
Tool.GripUp =["Classic"..choice][4][1],holder["Classic"..choice][4][2],holder["Classic"..choice][4][3]);


Well this code sets the grip positions correctly when FIRST equipped, but as soon as it runs the lunge function, the grip positions don’t set correctly anymore and the sword lays sideways with the incorrect values in the properties. I even tried using the command bar to manually reset the grip positions and it doesn’t do a thing. It’s like the grip positions are locked for some reason. And unequipping the tool and re-equipping it doesn’t fix it. I have attached screenshots of the correct position and grip position vectors of the tool when first equipped and then the incorrect position and incorrect grip position vectors after the lunge function has run.

Wouldn’t it be better to store the grip values as vector 3’s instead of tables?

Hmm, yeah, that would be more efficient for sure. Thank you for the suggestion. But even if I do that, the problem still remains. I verified that it is correctly reading and inputing the values, it’s just locking grip attachment manipulation after the lunge function runs and I am completely stumped. Have you ever run into this before?

Just updated the tables to vector3 values. No change. Interestingly, it works flawlessly if I use the original sword mesh.

Is there any way the default character animation script running the lunge and slash arm movement could be screwing things up? I wouldn’t think that would affect the grip attachment at all…

I don’t think that’s the case. Whenever I use tools, I make the handle an invisible part, then I put a model in the tool of the actual item model and weld it to the handle. Maybe you could try that.

1 Like

I think that might work quite well actually. Wouldn’t have to mess with the tool grip cause you can just rotate and move the model while leaving the tool grip at it’s default value… Brilliant. Again, I’m terrible with tools, so I appreciate your guidance.

1 Like

You’re a life saver. That worked! Finally I’m making progress!

1 Like