I’m working on a beyblade game which lets the player control their bey and I don’t have much experience working with changing the player’s character and stuff so I wanted to know what’s a good way to go about doing movement?
Currently I’m just using a body gyro, body angular velocity and body velocity I assume I probably don’t need to be using all 3 of these, but yeah. Here’s the code I have for it.
if input.KeyCode == Enum.KeyCode.F then
--LaunchBey:FireServer(player)
if not beyLaunched then
bey = beys:FindFirstChild("StormPegasus"):Clone()
bey.Root.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(3,0,0)
bey.Parent = game.workspace.PlayerBeys
bey.Name = (player.Name.."s Beyblade")
--keeps the bey up (I think?)
local BG = Instance.new("BodyGyro")
BG.Parent = bey.Root
--spin
local BAV = Instance.new("BodyAngularVelocity")
BAV.AngularVelocity = Vector3.new(0,-25,0)
BAV.Parent = bey.Root
--movement
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(1000000, 0, 1000000)
local speed = 30
RunService.Heartbeat:Connect(function()
local moveDir = bey.Humanoid.MoveDirection
BV.Velocity = Vector3.new(moveDir.X,height,moveDir.Z) * speed
end)
BV.Parent = bey.Root
player.Character = bey
camera.CameraSubject = bey.Root
beyLaunched = true
end
end
if input.KeyCode == Enum.KeyCode.Space then
if (bey) and (bey.Root:FindFirstChild("BodyVelocity")) then
local maxForce = bey.Root.BodyVelocity.MaxForce
height = 20
bey.Root.BodyVelocity.MaxForce = Vector3.new(maxForce.X,600,maxForce.Z)
task.wait(0.5)
bey.Root.BodyVelocity.MaxForce = Vector3.new(maxForce.X,0,maxForce.Z)
end
end