HumanoidAttributes - Editing humanoid properties made easy

This is HumanoidAttributes, a simple module meant to eliminate conflicts and adding modifiers to humanoid properties.

This module is very simple to use! We stop conflicts by adding keys to when we change any humanoid property and checking for the key if we want to change it again. We can add modifiers that are added onto the humanoid property with a given key.

Example

local HumanoidAttributes = require(HumanoidAttributes)
	local HV = HumanoidAttributes.GetAttributes(Character)

	HV:Set("WalkSpeed", "LowHealth", 5)

	task.delay(3, function()
		HV:DestroySet("WalkSpeed", "LowHealth")
		HV:AddModifier("WalkSpeed", "PowerUp", 25)
	end)

	HV:RemoveModifier("WalkSpeed", "PowerUp")

Setup
Player Character

local HumanoidAttributes = require(game.ServerStorage.HumanoidAttributes)
			local Players = game:GetService("Players")

			Players.PlayerAdded:Connect(function(player: Player)
				player.CharacterAdded:Connect(function(Character: Model)
					HumanoidAttributes.SetC(Character)
				end)
			end)

Npc Character

local HumanoidAttributes = require(game.ServerStorage.Modules.HumanoidAttributes)

			workspace.DescendantAdded:Connect(function(descendant: Instance)
				if descendant:FindFirstChildOfClass("Humanoid") then
					HumanoidAttributes.SetC(descendant)
				end
			end)

if there are any bugs or questions please ask me
Discord: cact_

5 Likes

Wouldn’t it be easier if you just changed the property of a humanoid you want to be changed instead of using a whole module to do just that?

Sorry if that came off as rude but could you explain to me what this module does?

5 Likes

The reason we use a module to do that is so we don’t have conflicts

lets say we have a combat script to attack someone else, in this script the humanoid walkspeed is set to 6 then back to the original walkspeed of 16 after 1 second. Now lets say we have a running script that sets the humanoid walkspeed to 25. Using both of these scripts we could first fire the combat script then the run script, after 1 second the walkspeed should be 25 because we are running but is set back to 16 because of the combat script.

We can use HumanoidAttributes module to set a key to both scripts, In the combat script say we use the Set method and send the key as “Combat” and the Value as 6, after one second we can use the DestroySet method and send the key in as “Combat”. For the run script instead of using a set we can use a Modifier to set the runspeed, use the method AddModifier and send through the key which will be “Running” and set the value to 9, we set it to 9 instead of 25 because all the modifiers get added onto the base value.

sorry if this is a bad explanation

2 Likes

Cool. Would be nice if we could add modifiers that multiplied existing attributes and a priority list.

3 Likes