How to make player hold tool with both hands

Hello! This may not be scripting but there is a gun that I have as a tool. I want the gun to be held in different positions on the gun…does anyone know how to do this?
-Thank you!

7 Likes

Try and make an animation with the gun that puts both arms onto the gun in the spots you want them.

EDIT: And script it to activate the animation when the player has the gun equipped

3 Likes

I have no experience of scripting…

1 Like

Are you working with R15 or R6?

EDIT: (For animating purposes)

You really need welds.
There is a handle grip changer plugin as well.

This as well.

I believe the handle grip changer plugin that you’re referring to is only to edit the position of the grip (If we’re thinking of the same one).

1 Like

Hello,

When your tool is being equipped, try to add a WeldConstraint onto the second part’s handle connected to player’s hand of choice, then have the position to be set onto a player hand of choice. So when doing the animation and stuff, you can still hold onto the swords or dual-wielded weapons.

2 Likes

Add this to your handle

------local script ------ make sure your animation is action and looped------
local holdAnim = 12345678 ------ your animation

repeat wait() until game.Players.LocalPlayer.Character

local lp = game.Players.LocalPlayer

local sp = script.Parent

local anim = Instance.new(“Animation”)

anim.AnimationId = “rbxassetid://” … holdAnim

local holdtrack = lp.Character.Humanoid:LoadAnimation(anim)

sp.Equipped:connect(function() — plays when equipped

holdtrack:Play()

end)

sp.Unequipped:connect(function() — stops when Unequipped

holdtrack:Stop()

end)
I can give you a animation. this will make you gun be held with both hands

5 Likes

I will try it when I can! Thank you!

2 Likes

This will give you a custom idle and sprint animation ( i assume you don’t want to be stuck in the idle animation while sprinting )

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

repeat wait(1) until player.Character

local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local sprintSpeed = 30
local walkSpeed = 16
local crouchSpeed = 10
local equipped = false

local animation = Instance.new("Animation")
animation.Name = "Idle"
animation.Parent = script.Parent
animation.AnimationId = "rbxassetid://8269791536"
local animtrack = humanoid:LoadAnimation(animation)

local runAnim = Instance.new("Animation")
runAnim.Name = "Sprint"
runAnim.Parent = script.Parent
runAnim.AnimationId = "rbxassetid://6932225442"
local runAnimTrack = humanoid:LoadAnimation(runAnim)

local function beginSprint(input, gameProcessed)
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			local keycode = input.KeyCode
			if keycode == Enum.KeyCode.LeftShift and equipped then
				runAnimTrack:Play()
			end
		end
	end
end

local function endSprint(input, gameProcessed)
	if not gameProcessed then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			local keycode = input.KeyCode
			if keycode == Enum.KeyCode.LeftShift then
				runAnimTrack:Stop()
			end
		end
	end
end

script.Parent.Equipped:Connect(function()
	if character.Humanoid.WalkSpeed == sprintSpeed then
		runAnimTrack:Play()
	else
		animtrack:Play()
	end
	
	equipped = true
end)

script.Parent.Unequipped:Connect(function()
	animtrack:Stop()
	runAnimTrack:Stop()
	equipped = false
end)


UIS.InputBegan:Connect(beginSprint)
UIS.InputEnded:Connect(endSprint)



3 Likes

Your going to have to create the animations yourself though. I don’t think you need to use welds. You can just use the tool grip editor to get the correct placement for the handle.

I made a tutorial which links 2 other tutorials. If you would like, you can follow that. It might help you with what you’re trying to achieve.

https://devforum.roblox.com/t/how-to-animate-tool-handles-easily-specifically-melees-unsure-of-guns

could you give me an animation?

Yea, do you know how to export animations?
Export me! - Roblox.

in studio------
go to plugins-
then to animations-
and click on the model and it should show a animation interface–
then click the three dots and click export-
and after its exported then there should be a copy id or id for the animation then----v

------local script ------ make sure your animation is action and looped------
local holdAnim = 12345678 ------ the animation id

repeat wait() until game.Players.LocalPlayer.Character

local lp = game.Players.LocalPlayer

local sp = script.Parent

local anim = Instance.new(“Animation”)

anim.AnimationId = “rbxassetid://” … holdAnim

local holdtrack = lp.Character.Humanoid:LoadAnimation(anim)

sp.Equipped:connect(function() — plays when equipped

holdtrack:Play()

end)

sp.Unequipped:connect(function() — stops when Unequipped

holdtrack:Stop()

end)

1 Like

I sadly can’t access this tutorial

That reply is quite old. The tutorial I linked has been replaced, and is in much further depth than the previous. You can access it here