Holsterservice - Really Easy Tool Holstering Module

Now, I’m in no way the best, and in no way very good at object oriented programming, but I needed a custom tool system using welds and motor6ds and I found no solutions, so I tried my best to make one, and this is what I came up with! I’m making it public due to other people struggling with this/having to use accessories for tool holstering which is really annoying, having to create an accessory for every tool.

I am inexperienced at OOP and this will not be the best or most optimal, and you may have to edit it to fit your game style, please tell me if any bugs occur or if you know a way to further optimize the script.

Weapons require a Handle for now, but it has to be a model and not directly in the tool. Make sure to turn RequiresHandle off.

GET HOLSTERSERVICE

Example of use (Server-Script):

local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()

local holsterService = require(game.ReplicatedStorage.HolsterService)
holsterService.SetLibrary(game:GetService("ServerStorage"):FindFirstChild("WeaponModels")) -- Where your weapons are stored, it will automatically default to what I put here

local weapon = holsterService.createWeapon("Sword", char) -- Make sure that the string is the weapon model and that it's in your library, and char is the model you want to hold the weapon

weapon:Holster("Torso", CFrame.new(-1, -1, -1)) -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0

script.Parent.Equipped:Connect(function()
	weapon:Sheath("Right Arm", char["Right Arm"].RightGripAttachment.CFrame * CFrame.Angles(math.rad(180), 0, 0))  -- Arg 1 is the part of the model you want the weapon to weld to, Arg 2 is the C0
end)

script.Parent.Unequipped:Connect(function()
	weapon:Holster("Torso", CFrame.new(-1, -1, -1))
end)

The library and weapon module should be setup along the lines of this
image
But you’re always able to change the module to something that fits your game.

This is basic use, and yes I know the module is lacking in functionality and stuff, It’s just a basic use for welding tool models to characters and stuff. I can’t provide an example video yet as my obs keeps crashing, I’ll update with one soon.

Major-ish Updates:
(im not just putting small tweaks here)

28 Likes

Could you provide some images or videos of show this would look in game please thanks :heart:

1 Like

its honestly (most likely) not optimal but its easy

image
image
you can make custom equip animations and it works with clientcast/ custom unequip scripts etc
you can holster it to any limb, and rotate it using CFrame.Angles()

o ya ti works for custom rigs

you can also edit the module to what fits you most because im horrible at OOP lol

5 Likes

it looks nice! ill try the module later and see!

2 Likes

you know what would be great about this system? if it had jiggle physics when moving the character.
ive been tryna find out how to do it and have been slightly unsuccessful but one way ive thought of doing this is by animations but thats inefficient and ive seen other games do it without animations

1 Like

Use a ballsocketconstraint! It can produce effects similar to what you’re thinking of. (uh, hopefully)
example video

or a weld with certain physics which i cannot explain because i didn’t make this and have no clue how it works, probably changing the C0 in a render loop or something
example 2

I might update the module to be able to do this though, in the near future…

2 Likes

wait can u send the model of the weld with certain physics, or show me how to get it? cuz thats what im looking for, and i wanna add it to the module myself

1 Like

This looks amazing! This is exactly the kind of thing I need!
I am confused on how to set it up. Do I have both a model and a tool? or just the model? Where do I put the script?

1 Like

u insert the module into replicated storage and u make a new serverscript inside the tool u wanna use it for and u wanna use the tool.Unequipped function and do something like:
weapon:Holster(“Torso”, CFrame.new(-1, -1, -1))
you also wanna add this line to the start of the script under no function so it will holster when the tool is in your backpack and there is more to this just look up at the original post and it shows the full example

3 Likes

You only need the model, if you want you can make a custom tool, but I only use the tool for the equipped/unequipped event. The models I used are setup like this.
image
And remember you can always edit the module to your liking and tell me what you did with it, in fact I encourage it fully, it helps me and everyone on this page improve, and if it’s good enough I might add it to the module!

Also on a side note, it won’t play the default tool equip animation, so you’ll need to make a custom equip animation if you want that, or your hand will always just hang idly
image

while holding the tool (Which certain games want anyway so i kept it)

2 Likes

Hey! Thanks for the reply. I figured out where I went wrong and now it’s working perfectly! Thanks! This has saved me a lot of time.
I do have a question though, is it possible to change the weapon model on the fly? I’m assuming I would just create a new weapon using .createWeapon() but is there a way to deconstruct old weapons so there isn’t a bunch of weapons in the games memory?

1 Like

I’d just make a custom function for it by doing something like
weapon.Weapon:Destroy()

when you use createWeapon it returns a table with the weapon (weapon model) and the owner (owner of the weapon)

3 Likes

Okay thanks! If you’re able to index the model using weapon.Weapon could you do something like this?

weapon.Weapon = NewWeaponModel

Or would that break it?

(Sorry to keep bugging you)

2 Likes

Well, it’s complicated.
I am pretty sure that changing a variable inside of a function/thread creates a local clone of it just for that function

I could be wrong but something similar to that happens for me.

Changing the weapon model (I don’t know why you’d do this) can break it depending on the context, for example if you’re using clientcast/raycasthitbox or indexing a part in the model that the new model doesn’t have will break.

If you’re making a tool swapping system like a shikai from bleach it may be quite unoptimal, or you might need to create a whole new model

I’ll incorporate a changemodel function later maybe

Please give a big further context on why you want to change the model, or if you were just giving me an example of referencing the model

Also, I might change weapon.Weapon into weapon.Model

2 Likes

In the game I’m making, over the course of the game you get better weapons so I was just trying to see if there was an easy way to change the model. I can probably figure something out.

Thanks!

You can edit the module to your liking for custom behaviour like this, but I might push an update to allow stuff like this easily, for now you can probably add a function called
weapons:ChangeModel()
to the module and edit the behaviour however you want to if you know OOP

2 Likes

yo i’m the guy who made that
all you gotta use is a spring module and the torso’s velocity
after that you can apply the position from the spring to the C0
it’s like applying the mouse delta to make a viewmodel lerp smoothly

2 Likes

yea ive already made my own thru the fe gun kit spring module and editing the c1 and stuff with spring accelerate and all that, thanks for the help tho!

3 Likes

Can you make this also for R15? I think that would be way cooler and look cooler aswell

1 Like

This should work for both R6 and R15, what problems are you experiencing?
if you’re trying to holster a weaponinstance just replace “Torso” with “UpperTorso”, the first argument is what limb it should be relative to (hence how it works with custom rigs etc)

1 Like