Motor6d not working at all

i have a script that detect input from a player, if its e then it fires a remote and the server connects it to a module script, once its connected it makes the weapon on their back transparent, it clones the knife from repstorage and parents it to the left arm and the motor6d, but it doesnt spawn anywhere next to the player and it doesnt keep it next to the player
//LOCAL SCRIPT//

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp  = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local animator : Animator = hum:WaitForChild("Animator")
local Key = "AssasinEquip"
local rs = game.ReplicatedStorage
local Event = rs.Events:WaitForChild("MainRemote")
local db = false
local Equipped = false
local Stationary_Knife = char.Torso:WaitForChild("Knife (Model)")
local anim = game.ReplicatedStorage.Animations.AssasinAnims.EquipAnimation

local function EquipWeapon()
	Equipped = true
end

local function HandleInput(input : InputObject, gpe)
	if gpe then
		return
	end
	if db then
		return
	end
	if input.KeyCode == Enum.KeyCode.E then
		db = true
		local CloneKnife = game.ReplicatedStorage.ITEMS.Knife["Knife (Model)"]:Clone()
		local Left_Arm = char:WaitForChild("Left Arm")
		CloneKnife.Parent = Left_Arm
		local Anim = animator:LoadAnimation(anim)
		Event:FireServer(Key, "Equip", Stationary_Knife,CloneKnife, hrp.CFrame * CFrame.new(0,0,1), Left_Arm,Anim)
		Anim:Play()
		task.wait(Anim.Length + 1)
		db = false
	end
end

uis.InputBegan:Connect(HandleInput)

///SERVER SCRIPT///

local event : RemoteEvent = game.ReplicatedStorage.Events:WaitForChild("MainRemote")
local MOD = require(game.ServerStorage.MODULES.HandleWeapon)

local function HandleInput(plr,KEY : string, SecondaryKey : string, Weapon : Part,RepWeapon : Part,POS : CFrame, OtherPart : Part, Anim)
	if KEY ~= "AssasinEquip" then 
		return
	end
	if SecondaryKey == "Equip" then
		MOD.Equip(Weapon, RepWeapon,POS,OtherPart,Anim)
	end
	if SecondaryKey == "Unequip" then

	end
end
event.OnServerEvent:Connect(HandleInput)

///MODULE SCRIPT///

local HW = {}
local Animmod = require(game.StarterPlayer.StarterCharacterScripts.PlayerAnimation.ClientAnimHandler)
function HW.Equip(Weapon : Part,RepWeapon, POS, OtherPart, Anim) : Motor6D
	print("Running")
	local m6 = Instance.new("Motor6D")
	Weapon.Transparency = 1
	m6.Name = OtherPart.Name
	m6.Enabled = true
	m6.Part0 = OtherPart
	m6.Part1 = RepWeapon
	m6.C1 = POS
	m6.Parent = OtherPart
	return m6
end

return HW
1 Like

the cframe should be local to the parts, and not treated as if they are in world space

1 Like

Hey, I made adjustments to ensure the knife spawns correctly on the player’s arm and follows their movements accurately.

Hopefully this fixes you issue :slight_smile:

Local Script:

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp  = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local animator : Animator = hum:WaitForChild("Animator")
local Key = "AssasinEquip"
local rs = game.ReplicatedStorage
local Event = rs.Events:WaitForChild("MainRemote")
local db = false
local Equipped = false
local Stationary_Knife = char.Torso:WaitForChild("Knife (Model)")
local anim = game.ReplicatedStorage.Animations.AssasinAnims.EquipAnimation

local function EquipWeapon()
	Equipped = true
end

local function HandleInput(input : InputObject, gpe)
	if gpe then
		return
	end
	if db then
		return
	end
	if input.KeyCode == Enum.KeyCode.E then
		db = true
		local CloneKnife = game.ReplicatedStorage.ITEMS.Knife["Knife (Model)"]:Clone()
		local Left_Arm = char:WaitForChild("Left Arm")
		CloneKnife.Parent = Left_Arm
		local Anim = animator:LoadAnimation(anim)
		Event:FireServer(Key, "Equip", Stationary_Knife, CloneKnife, Left_Arm, Anim)
		Anim:Play()
		task.wait(Anim.Length + 1)
		db = false
	end
end

uis.InputBegan:Connect(HandleInput)

Server Script:

local event : RemoteEvent = game.ReplicatedStorage.Events:WaitForChild("MainRemote")
local MOD = require(game.ServerStorage.MODULES.HandleWeapon)

local function HandleInput(plr, KEY : string, SecondaryKey : string, Weapon : Part, RepWeapon : Part, OtherPart : Part, Anim)
	if KEY ~= "AssasinEquip" then 
		return
	end
	if SecondaryKey == "Equip" then
		MOD.Equip(Weapon, RepWeapon, OtherPart, Anim)
	end
	if SecondaryKey == "Unequip" then
	end
end
event.OnServerEvent:Connect(HandleInput)

Module Script:


local HW = {}
local Animmod = require(game.StarterPlayer.StarterCharacterScripts.PlayerAnimation.ClientAnimHandler)

function HW.Equip(Weapon : Part, RepWeapon : Part, OtherPart : Part, Anim)
	print("Running")
	local m6 = Instance.new("Motor6D")
	Weapon.Transparency = 1
	m6.Name = OtherPart.Name
	m6.Part0 = OtherPart
	m6.Part1 = RepWeapon

	m6.C0 = OtherPart.CFrame:Inverse() * OtherPart.CFrame
	m6.C1 = RepWeapon.CFrame:Inverse() * RepWeapon.CFrame

	m6.Parent = OtherPart
	return m6
end

return HW

What do yo mean, im making it so its multypling it by the humanodirootparts position how is it ending up there

this did not work, the problem is the motor6d isnt activating, the propery activated isnt on

1 Like

Figured it out, parameters are being passed down incorrectly, idk how since i did do most of it right but i can figure this out

1 Like