I have been on a bossfight and one of the attacks is that it lunges with a sword, however i cant seem to rotate the sword, the sword is welded with a WeldConstraint to the arm.
I have tried using .Rotation and CFrame but neither seemed to work correctly, i also tried using a normal weld and a motor6d but it doesn’t achieve what i wanted.
function equipWeapon(weapon, arm) --equips the weapon and welds it to the arm
local armPos = arm.CFrame - Vector3.new(0, 1, 0)
local weapon = Weapons[weapon]:Clone()
weapon.CFrame = armPos
local weld = Instance.new("WeldConstraint")
weld.Part0 = weapon
weld.Part1 = arm
weld.Parent = weapon
weapon.Parent = arm.Parent
return weapon
end
module.SwordAttack = function(player, BossHumanoidRootPart, BossHumanoid)
local myRoot = player:FindFirstChild("HumanoidRootPart")
local unseathSound = Sounds.BMUnsheath
local slashSound = Sounds.BMSwordSlash
local lungeSound = Sounds.BMSwordLunge
local rootPos
local POSITION
local sword = equipWeapon("Sword", BossHumanoidRootPart.Parent["Right Arm"])
animations[4]:Play()
unseathSound:Play()
task.wait(0.4)
for i = 1, 5 do --attacks 5 times
rootPos = plrVector(myRoot, BossHumanoidRootPart)
POSITION = rootPos + (myRoot.CFrame.LookVector * 4.5)
BossHumanoidRootPart.CFrame = CFrame.new(POSITION, rootPos)
if i == 5 then
sword.Orientation = Vector3.new(-90, 0, 0) --Here i try to rotate it but it doesnt work
animations[3]:Play()
lungeSound:Play()
else
animations[math.random(1, 2)]:Play()
slashSound:Play()
end
task.wait(0.7)
end
sword:Destroy()
end