#Need help, attaching mesh on arm using motor6D

1 messages · Page 1 of 1 (latest)

summer leaf
#

so i made a custom rig using motor6D, i attached a mesh onto an R6 arm, put an animation on it. And now all i have to do (I think) is to attach the same mesh the same way i did to the rig to a player, i have no idea how

Now this is what AI came up with, i reviewed it and i cant see anything wrong, and the supposed output also shows that it works, but it doesnt when i ran the game:

||-- ServerScriptService/TridentAttacher.lua

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

-- Wait for the Trident part to exist in ServerStorage
local tridentPart = ServerStorage:WaitForChild("Trident", 10)
assert(tridentPart, "❌ Trident part not found in ServerStorage!")

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
-- Wait until character is fully parented to the workspace
char.AncestryChanged:Wait()

    -- For R6, the arm is named "Right Arm"
    local rightArm = char:WaitForChild("Right Arm", 10)
    if not rightArm then
        warn("Right Arm missing for player: "..player.Name)
        return
    end

    -- Clone the trident into the character
    local tridentClone = tridentPart:Clone()
    tridentClone.Parent = char

    -- Make sure both parts are unanchored (Motor6D needs that)
    rightArm.Anchored = false
    tridentClone.Anchored = false

    -- Create Motor6D and weld
    local motor = Instance.new("Motor6D")
    motor.Name   = "TridentMotor"
    motor.Part0  = rightArm
    motor.Part1  = tridentClone
    -- Adjust C0 for correct grip; tweak as needed
    motor.C0     = CFrame.new(0, -1, 0) * CFrame.Angles(0, math.rad(90), 0)
    motor.Parent = rightArm

    -- Snap orientation
    tridentClone.CFrame = rightArm.CFrame * motor.C0

    print("✅ Trident attached on "..player.Name.."'s Right Arm via Motor6D")
end)

end)||