I currently have this code running every frame which handles moving and tilting the bey and I wanna implement spinning now, but most of my attempts of caused the bey to go flying or break the tilt.
function BeyMovement:moveBey()
local root = self.beyModule.beyModel.HumanoidRootPart
local cameraLookVector = workspace.CurrentCamera.CFrame.LookVector
local turnRot = CFrame.new(root.CFrame.Position, root.CFrame.Position + Vector3.new(cameraLookVector.X, 0, cameraLookVector.Z))
self:calculateAcceleration()
self.fakePart.CFrame = turnRot * CFrame.new(self.leftAcceleration, 0, self.forwardAcceleration)
local speedDistance = (root.Position - self.fakePart.Position).Magnitude
local speed = CFrame.new(turnRot.Position, self.fakePart.CFrame.Position).LookVector * (speedDistance * 3)
if isRealNumber(speed.X) or isRealNumber(speed.Z) then
root.Velocity = speed
else
root.Velocity = Vector3.new()
end
end
function BeyMovement:tiltBey()
local root = self.beyModule.beyModel.HumanoidRootPart
local cameraLookVector = workspace.CurrentCamera.CFrame.LookVector
local turnRot = CFrame.new(root.CFrame.Position, root.CFrame.Position + Vector3.new(cameraLookVector.X, 0, cameraLookVector.Z))
self.previousTilt = self.previousTilt:Lerp(self:calculateTilt(), 0.1)
root.CFrame = CFrame.new() * turnRot * self.previousTilt
end