ModelEquip - Easily weld models to the players character

ModelEquip

Module | Documentation | Source Code

Introduction

ModelEquip allows users to easily weld and unweld models to the characters, which is useful when adding weapons, tools, armor, and other items to the player.

Implementation

To start, go ahead and grab the module and place it in ReplicatedStorage.

After inserting the module, make sure to update the settings to fit your liking. They can be found in the module’s attributes. Documentation for each setting can be found below in the “Documentation” section of this post.

Next, require the module from your script using require(ReplicatedStorage.ModelEquip).

After requiring the module, make sure you initialize it using ModelEquip:Init(). Initializing the module checks for updates (if DetectUpdates is enabled) and watches for player deaths (if PersistDeath is enabled).

That’s it for setting up the module! Now, we need to create our first model.

Inside the module, you will find an example folder. This folder shows the structure your models should follow.

example1

The parts folder contains R15 and R6 body parts for positioning your model on the character. Make sure the parts are named the same as they would be in the character, and that the ObjectValues are set to the proper part.

The model is the model which will be welded to the player. Your model must have a PrimaryPart. You can weld it yourself, or enable settings[“AutomaticallyWeld”], which will weld the model automatically.

Now, parent the folder to the module, and you are set!

Once all of these steps have been completed, you are ready to start using the module! See the documentation section below for functions and example usage.

Documentation

SETTINGS:

AutomaticallyWeld

If true, models will be automatically welded before being added to the character.

PersistDeath

If true, characters will respawn with models until they are removed.

DetectUpdates

If true, the module will check & notify you if an update available.

FUNCTIONS:

ModelEquip:Init()

Init prepares the module for use by checking for updates and watching for player deaths, depending on your settings.

ModelEquip:Add(humanoid:Humanoid, model:string, overridePersistant:boolean)

Adds the specified model to the character.

ModelEquip:Remove(humanoid:Humanoid, model:string)

Removes the specified model from a character.

Example Usage

Below is a script that adds the example model supplied with the module to a player’s right leg when they join. PersistDeath is enabled, so the model will remain on the player even after they die.

local Players = game:GetService("Players")

local ModelEquip = require(script.ModelEquip)

ModelEquip:Init()

local function PlayerAdded(player)
	local CharacterAdded

	CharacterAdded = player.CharacterAdded:Connect(function(character)
		repeat task.wait() until character:FindFirstChildOfClass("Humanoid")

		ModelEquip:Add(character:FindFirstChildOfClass("Humanoid"),"Example")

		CharacterAdded:Disconnect()
	end)
end

for i, v in Players:GetPlayers() do
	PlayerAdded(v)
end

Players.PlayerAdded:Connect(PlayerAdded)

Conclusion

In the end, I hope that others will find this module useful. I would love to add more features, please let me know if there is anything that you would like to see added. If you have any suggestions or changes, I would love to hear those as well. Thank you for reading.

Do you think this is a useful module?

  • Yes
  • No

0 voters

11 Likes

This seems great, and I am definitely going to try it out. I actually was needing something like this for my game’s clothing system. Good work.

1 Like

Heck man that module will dif save my time, many thanks

2 Likes

Just a suggestion
Expand this into replacing roblox tools (that system is buggy and old)

When making a custom character the tool system requires a humanoid. I need to parent it to a “ToolUser” and then parent it back to the character I want to use the tool.