I created a few animations for my custom tool-less weapon, but the animations are not being applied correctly.
Looking at the animations I made, it is smooth.
But when I tested it in game… The weapon clips into me! And the blocking animation doesn’t even play correctly!
I am stumped. I went to refer online through video tutorials, and they use the same Motor6D method and it works for them!
Motor6D Creation function. done on a server script that handles all the weapons
local function AttachWeapon(player, weaponName)
local char = player.Character
if not char then return end
local rightArm = char:FindFirstChild("Right Arm")
if not rightArm then return end
local weaponTemplate = WeaponModels:FindFirstChild(weaponName)
if not weaponTemplate then return end
local currentModel = char:FindFirstChild("ActiveWeapon")
if currentModel then currentModel:Destroy() end
local newWeapon = weaponTemplate:Clone()
newWeapon.Name = "ActiveWeapon"
newWeapon.Parent = char
local handle = newWeapon:FindFirstChild("Handle")
if not handle then return end
local CFrameValue = newWeapon:FindFirstChild("Value")
if not CFrameValue then
warn("No CFrameValue found in " .. weaponName)
return
end
local motor = Instance.new("Motor6D")
motor.Part0 = rightArm
motor.Part1 = handle
motor.C1 = CFrameValue.Value
motor.Parent = rightArm
char:SetAttribute("EquippedWeapon", weaponName)
end
Animation function, handled on the client in StarterPlayerScripts
local function LoadAnimation(name)
if not CurrentWeaponData or not CurrentWeaponData.Animations[name] then return nil end
if LoadedAnims[name] then return LoadedAnims[name] end
local animObj = Instance.new("Animation")
animObj.AnimationId = CurrentWeaponData.Animations[name]
if not Animator then return nil end
local track = Animator:LoadAnimation(animObj)
if name == "Block" or name == "Idle" then
track.Looped = true
end
LoadedAnims[name] = track
return track
end
When the Animation is played
local function HandleAttack(inputState)
if inputState ~= Enum.UserInputState.Begin then return end
if not CurrentWeaponName then return end
if Character:GetAttribute("IsBlocking") then return end
if not CanAttack then return end
if IsDashing then return end
if CurrentWeaponData.WeaponType == "Ranged" then
CanAttack = false
local track = LoadAnimation("M1")
if track then track:Play() end
local mouse = Players.LocalPlayer:GetMouse()
local targetPos = mouse.Hit.Position
CombatRemote:FireServer("Fire", targetPos)
task.wait(CurrentWeaponData.FireRate)
CanAttack = true
else
CanAttack = false
local track = LoadAnimation("M1")
if track then track:Play() end
CombatRemote:FireServer("M1")
task.wait(CurrentWeaponData.AttackCooldown)
CanAttack = true
end
end
Note that
- The Motor6D values I initalised in the scripts are exactly the same as the original Motor6D values I made when animating
- AnimationPriority is set to Action
pls save me

