How to keep character moving mid air, even if they let go of W

hi! I don’t know what is required to keep a character moving mid air until they have landed. I want the character to keep moving mid air even if they let go of W halfway. Is this possible and if so what will I need to use.

An example of this are games such as Evade, Surf, Bhop.

4 Likes

im sorry but i dont know how to script :frowning_face:

1 Like

i had to empty this cus som1 got into my pc and replied in my account :grinning::gun:

1 Like

Hello I’m am currently typing this on a phone it’s been a little bit since you’ve made this post but I think I Might Have a solution to figure if the player is moving and then stops I don’t have have a solution to keep them moving to do that you’d have to get velocity’s and stuff which Im not equipped with at this moment but, what you would have to do is check if the player jumped there are many ways of checking for jumping one but not the best way is Enum.HumanoidStateType.Jumping or FreeFalling, put that in an if then, then you need to check if player has stopped moving during the period of time while in the air which you can define by getting the humanoid in a number of various ways one being local hum = game.Players.Localplayer.Character:WaitForChild(“Humanoid”) then to see if they’ve stopped moving you want to check every frame or tick while the player is falling so in that if then where we checked if the player was falling/Jumping we need to put a while loop so do while hum.MoveDirection.Magnitude == 1 do, “MoveDirection” is getting the direction that the player is moving and “magnitude” is getting the Speed but it can only hold 1’s and 0’s so 1 would be pressing a key like was 0 would be not pressing any keys, I think you see where this is going, inside of the while loop we would put task.wait() with an empty value in the brackets this is CRUCIAL for the script not to break and freeze your game, next we want to actually check for movement if hum.MoveDirection.Magnitude == 1 then, I will leave this blank but you would probably want to store the velocity value here, after checking right before the end it just created after the if put and else, what that’s doing is checking for any number other than one if one isn’t value but there are only two possible values it can be one or zero so it will check for zero so if it fing zero you could change the players velocity by the stored velocity I just said to store in the other if then and every millisecond or so deplete that stored velocity number by a decimal or so depending on how fast you want them to stop and then when they start moving again stop using that stored velocity and just start using the built in velocity that makes the player move until they jump again where you would restore the value until they stop moving midair hope that helps if it doesn’t comment back and I might make the code and just give it to you

1 Like

Then don’t comment. If this doesn’t apply to you directly or you don’t know how to help, don’t make a post.

2 Likes

Add velocity if player is in air and if input has ended on w,a,s,d

1 Like

I take it you have a fly script and just want it to continue even if the W is let off. Someplace in that script is a function something like this …

uis.InputEnded:Connect(function(input, processed)
	if input.KeyCode == Enum.KeyCode.W then
		endFlying()
	end
end)

Replace that with something like this …

HP:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	endFlying()
end)

HP being the player Humanoid part.

Hey I don’t think he was talking about flying more so like that mechanic in evade we’re if you jump and let go midair you slowly start to stop instead of just coming to a sudden halt

Maybe try humanoid:ChangeState(Enum.HumanoidStateType.Physics), then player couldn’t control the character

Do the same thing. But, also in the 1st script cut the velocity in 1/2
As in use the 1st script to do just that and the 2nd to stop the flying event.

local plyr : Player = player
local character : Model = plyr.Character
local hrp : Part = character.PrimaryPart

local _ : LinearVelocity = Instance.new("LinearVelocity")
_.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
_.VectorVelocity = Vector3.new(0, 0, 0)

?

1/2-ish of whatever it was when you let go. Really can’t say without seeing the script and having something to work with. You would think just a bit of upwards force would be all that would be needed at that point till they hit the ground.

Can you show your sprint script ?

1 Like

I do not know whether you have found a Solution to your problem yet but here Is a script that I made that allows the player to retain their velocity While In the air

wait(.5)
local run = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local createOnce = false

run.RenderStepped:Connect(function()
	if hum.FloorMaterial == Enum.Material.Air then
		if createOnce == false then
		createOnce = true	
			
		vectorVel = Instance.new("BodyVelocity")
		vectorVel.MaxForce = Vector3.new(10000,0,10000) -- dont change the 0 
		vectorVel.P = 1000
		vectorVel.Parent = hrp
		vectorVel.Velocity = (hum.MoveDirection) * hum.WalkSpeed
			
			
			repeat
				for _, v in pairs(char:GetChildren()) do
					if v:IsA("Part") or v:IsA("BasePart") or v:IsA("MeshPart") then
						v.Touched:Connect(function(hit)
							if hit and hit.Parent ~= char or hit ~= char then	
								vectorVel.Velocity = -hrp.CFrame.LookVector * .7
							end	
						end)
					end
				end
				task.wait()
			until hum.FloorMaterial ~= Enum.Material.Air 
		end
	else
		if vectorVel then
			createOnce = false
			vectorVel:Destroy()
		end
	end
end)














function errorHider()
	vectorVel.P = 1000
end 

My way of checking for Collisions probably Isn’t the best considering I’m just checking to see if every thing inside of the character that isn’t a script is getting touched and since it’s in a repeat loop I Don’t know If on certain occasions It will lag your game but that’s what I came up with

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.