I’m trying to make a melee weapon similar to those in Combat Initiation, but I dont really know how to make it smoothly rotate the character to the orientation.
This is how it currently works
How i intended it to work
So as an alternative, currently it snaps the character to where the cursor is facing. Any suggestions on how? Here’s the snippet of code.
equipped = true
if player.Character and UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and equipped then
local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
local mouseLocation = Vector3.new(mouse.Hit.X, rootPart.Position.Y, mouse.Hit.Z)
rootPart.CFrame = CFrame.new(rootPart.Position, mouseLocation)
hum.AutoRotate = false
end
end)
tool.Unequipped:Connect(function()
equipped = false
hum.AutoRotate = true
end)
local function onAim()
if player.Character and UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and equipped then
local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
local mouseLocation = Vector3.new(mouse.Hit.X, rootPart.Position.Y, mouse.Hit.Z)
rootPart.CFrame = CFrame.new(rootPart.Position, mouseLocation)
hum.AutoRotate = false
else
hum.AutoRotate = true
end
end
ContextActionService:BindAction("Aim", onAim, false, Enum.UserInputType.MouseMovement)```