Auto Equip Weapons?

Hey!

I was wondering what the best way to auto-equip weapons are - meaning having them in the players hand without equipping/pressing “1”.

I have my damage script, my cooldown script and animation scripts all sorted out (Thanks for the help on them!) but just needed a boost starting this script.

I am not asking for a free script, I am asking where to start - what sort of function do I use etc…

Any walk through things are appreciated!

Many thanks!

2 Likes

You can call :EquipTool() on the character’s humanoid:

local tool = wherever.the.tool.is
Character.Humanoid:EquipTool(tool)
2 Likes

Ok, thanks that worked!

However, I am aiming to have the same/similar thing to World // Zero, where they have the weapons already equipped, with no way of unequipping it.

How could this be achieved? Where should I start?

To unequip toools use Humanoid:UnequipTools() Also be sure to mark solution so others know the problem is solved :+1:

1 Like

Would this prevent the player from unequipping it?

I am attempting to prevent them from unequipping the tool.

You could also set the parent of the tool to the character as well. Like if I were to auto equip a sword from the ReplicatedStorage:

local tool = game.ReplicatedStorage.Sword:Clone()

tool.Parent = player.Character

Oh, to prevent them from un-equipping the tool use this:

tool.Unequipped:Connect(function()
	game:GetService("RunService").RenderStepped:Wait() --wait one frame
	game.Players.LocalPlayer.Character.Humanoid:EquipTool(script.Parent)
end)
2 Likes

Works like a charm!

Thanks alot!

is there a way to remove the icon, that shows the tool has been equipped?

Many thanks again!

If you mean the blue that goes around it when you equip it, I don’t think it can be removed

The backpack gui can be disabled. Put this in any localscript:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
1 Like

Usually, this is where a custom tool system would come into place. Some developers don’t want the native behaviour that’s given with tools (it’s actually only related to the backspace feature), so they write custom tool systems. This way, you don’t need to force equip tools.

A note (cc @DatabaseReplace): don’t use RenderStepped if you aren’t doing something related to the camera or character that realistically needs to happen before frames render. It’s common for developers to misuse RenderStepped for purposes where it should not be used. Use Heartbeat instead.

5 Likes

When I play, the tool starts off somewhere else - not in the players hand, when I press 1, the tool goes to the players hand. How can I make it so it is always in the players hand?

I am going to try:
tool.Position = Humanoid.LowerRightArm.Position

If you liked my idea of a custom tool system, consider this post:

I don’t think I mention this very often when I bring it up, but through some personal deduction and post reading - you know Dungeon Quest? If that’s the kind of tool system you’re looking for, it does use accessories like this as well.

This post can show you how to add tools to players’ hands. The next step would be figuring out how to set up a system in such a way that you can activate certain actions (e.g. swinging a sword) based on if a tool’s been equipped.

2 Likes