How I Can Make My Code Better

Hi Guys, I Have Script To Jump, Dont Ask Me Why, Just Look!

local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid and humanoid.FloorMaterial ~= Enum.Material.Air then

			local primaryPart = character.PrimaryPart
			local lookVector = primaryPart.CFrame.LookVector

			local bodyVelocity = Instance.new("BodyVelocity")
			bodyVelocity.Velocity = Vector3.new(0, 40, 0)
			bodyVelocity.MaxForce = lookVector * 50 + Vector3.new(4000 , 6000, 4000)
			bodyVelocity.P = 1250

			bodyVelocity.Parent = character.PrimaryPart

			game:GetService("Debris"):AddItem(bodyVelocity, 0.1)
		end

But My Character Moving Not Well As I Want, How I Can Improve My Code?

2 Likes

What do you want to achieve and what is the issue (include screenshots / videos if possible) and what solutions have you tried so far?

There’s a much simpler way…

local uis = game:GetService("UserInputService")

local function onJump()
    if humanoid.FloorMaterial ~= Enum.Material.Air then
        humanoid:ChangeState(Enum.HumanoidStateType.Jumping
    end
end

uis.JumpRequest:Connect(onJump)

And if you need to change how far the player jumps, just modify the humanoid’s JumpHeight.

Ima Making Voice Controled Game, So when i jump and go forward its a bit stopping for a some seconds