Script does not create Motor6D

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to follow a tutorial but every time I do it I get this very annoying error:

here’s the tutorial:

but incase you don’t want to go through it I’ll explain the issue.

I have this server script:


game.Players.PlayerAdded:Connect(function(plr)			
	plr.CharacterAdded:Connect(function(char)		
		local M6D = Instance.new("Motor6D")
		M6D.Parent = char.UpperTorso
		print(M6D.Parent)
		M6D.Name = "ToolGrip"
		print(M6D.Name)
		
		
		if char.UpperTorso:FindFirstChild("ToolGrip") then
			print("Good")
		else
			print("What")
		end
	end)
end)

game.ReplicatedStorage.ConnectM6D.OnServerEvent:Connect(function(plr,location)
	local char = plr.Character
	char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
	char.UpperTorso.ToolGrip.Part1 = location
end)

game.ReplicatedStorage.DisconnectM6D.OnServerEvent:Connect(function(plr)
	plr.Character.UpperTorso.ToolGrip.Part1 = nil
end)

that is supposed to make a new motor6d named “ToolGrip” but it does not. I’ve tried different formatting and everything else, but to no avail. I even tried adding the motor6d on the server myself, and it did nothing.

Here’s the client script:

local Players = game:GetService("Players")

local WeaponTool = script.Parent.Pistol
local player = Players.LocalPlayer

local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end

local char = character
print(char.Name)
print(character.Name)
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local HoldGunAnimation = Instance.new("Animation")
-- Set its "AnimationId" to the corresponding animation asset ID
HoldGunAnimation.AnimationId = "rbxassetid://7225805475"
local HoldGunAnimationTrack = animator:LoadAnimation(HoldGunAnimation)






script.Parent.Equipped:Connect(function()
	game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.BodyAttach)
	char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
	char.UpperTorso.ToolGrip.Part1 = WeaponTool.BodyAttach


HoldGunAnimationTrack:Play()




	
end)

script.Parent.Unequipped:Connect(function()
	game.ReplicatedStorage.DisconnectM6D:FireServer()

HoldGunAnimationTrack:Stop()
end)

i dont exactly bothered reading what your trying to do but if your looking to create motor6D and your trying to do animation then just use this because i have played with motor6D for a couple of days with scripts and it drived me insane

https://www.roblox.com/library/1274343708/RigEdit-Lite?Category=Plugins&SortType=Bestselling&SortAggregation=AllTime&SearchKeyword=rigedit&CreatorId=0&Page=1&Position=2&SearchId=c38de886-74fe-4c0e-8df4-f327ad175cb0

a tutorial if you dont know how to use it

never use a script to create motor6D

1 Like

I honestly wouldn’t use a script to do this if I knew another way, but the motor6D is made to connect the player and the gun when the gun is equipped (During gameplay)