Item tool Grip on torso

I am trying to make a tool but when I equip any tool it just goes to my torso and gives an error
when I remove the line of code it still goes to the torso. Here is the error:

Players.ForgottenDogYT.Backpack.Bat.LocalScript:8: attempt to index nil with ‘Torso’

here is the script:

local char = game.Players.LocalPlayer.Character
local WeaponTool = script.Parent

script.Parent.Equipped:Connect(function()

	game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.Weapon)
	
	char.Torso.ToolGrip.Part0 = char.Torso
	char.Torso.ToolGrip.Part1 = WeaponTool.Weapon

end)

WeaponTool.Unequipped:Connect(function()

	game.ReplicatedStorage.DisconnectM6D:FireServer()

end)

You need to change your character variable and make it wait for the character. It’s simple, just do this:
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

1 Like
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

Try this. This should remove the given error of a missing character.

1 Like

Do I put this before the line of code where it errors?

You just delete the entire first line and put it.

1 Like

Put it in place of your char variable declaration.

1 Like

It removed the error but the tool still goes to the torso

Wait. You did not want that? Try welding it to the right hand.

my friend helped me make the but he made the torso part. I dont want the tool to go to the torso but to the Normal tool holding hand

You can do what @Anurag_UdayS said.
But, if you want, you can change the C1 property of the motor 6D.
Here’s more about the C1 property!
You can set it by doing this:
char.Torso.ToolGrip.C1 = CFrame.new(0,1,0) (Example)

yeah but I want the tool grip to be at the hand.

You can just insert the part that you want to be holded into the tool object and name it “Handle” (without quotation marks) and then delete the script.
Roblox is going to do this for you!

1 Like

If you remove these two lines completely, Roblox’s default systems will do the work for you, unless you changed them after the fired event.

I did. It continues on the torso (Edit) I have a script in ServerScriptService which also has the toolgrip thing:

game.ReplicatedStorage.ConnectM6D.OnServerEvent:Connect(function(plr,location)

      local char = plr.Character
      char.Torso.ToolGrip.Part0 = char.Torso
      char.Torso.ToolGrip.Part1 = location


end)

game.ReplicatedStorage.DisconnectM6D.OnServerEvent:Connect(function(plr)
    plr.Character.Torso.ToolGrip.Part1 = nil
end)
game.Players.PlayerAdded:Connect(function(plr)		
plr.CharacterAppearanceLoaded:Connect(function(chr) -- Character loads
for i,v in pairs(chr:GetChildren()) do -- Get every part within character
if v:IsA("CharacterMesh") then -- If it is a character mesh, which is used to render them
v:Destroy() -- Destroy it if it is.
end
end
end)
	
plr.CharacterAdded:Connect(function(char)
				local uppertorso = char:WaitForChild("Torso")
		local M6D = Instance.new("Motor6D", char.Torso)
		M6D.Name = "ToolGrip"
end)
end)

workspace.ChildAdded:Connect(function(child)
if child:IsA("Hat") or child:IsA("Tool") or child:IsA("Accessory") then
child:Destroy()
end
end)

Try this. I believe your current tool does not have a direct child named “Handle”, or it is not incorporated properly.

1 Like

My tool handle is called Weapon but if i change it to handle it works but i get multiple errors saying that Weapon Does not exis

Try using Ctrl + Shift + F to find all the lines causing the error with the word “Weapon”, then replace them to “Handle”.

1 Like

Can you send us the weapon script?
That’s happening because the script can’t indentify the weapon anymore… :thinking:

Replace them to Handle right? because thats the handle name

2 Likes

Exactly.
I think this is going to fix it.