AssemblyLinearVelocity and It's corresponding impusle providing inconsistent results

if input.KeyCode == Enum.KeyCode.Space then
		
		if JumpCooldown == false then
			JumpCooldown = true
			humanoid.WalkSpeed = 0
			
			
			
			
			
			RootPart.AssemblyLinearVelocity = RootPart.AssemblyLinearVelocity + Vector3.new(0,30,0)
			--Character.PrimaryPart:ApplyImpulse(Vector3.new(0,900,0))
			wait(0.1)
			
			repeat wait ()		
				--note to put something here later lol
			until humanoid.FloorMaterial ~= Enum.Material.Air
			humanoid.WalkSpeed = MaxSpeed
			
			
			
			JumpCooldown = false
		
		end
		end
end)

Above is a script that is supposed to make the player’s humanoid root part have a y velocity increase of 30, creating a fake jump. This works except sometimes the velocity doesn’t seem to apply. I can tell the velocity is being applied but is being removed quickly (within the frame) after application on the times where it doesn’t seem to work. Can anyone tell me why?

Hi!

I’m returning your script back, because it works flawlessly for me. Only changes that I made are replacing wait() with RunService.Heartbeat:Wait(), because it’s a much better option, and AssemblyLinearVelocity line.

Maybe the code you are inserting here is causing inconsistency.

local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local character = Players.LocalPlayer.Character or Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")

local MAX_SPEED = humanoid.WalkSpeed

local jumpCoolDown = false

UIS.InputBegan:Connect(function(input)
	if (input.KeyCode == Enum.KeyCode.Space) then
		if (not jumpCoolDown) then
			jumpCoolDown = true
			humanoid.WalkSpeed = 0
			rootPart.AssemblyLinearVelocity = Vector3.new(0, 150, 0)
			wait(0.1)
			repeat RunService.Heartbeat:Wait()
			until humanoid.FloorMaterial ~= Enum.Material.Air
			
			humanoid.WalkSpeed = MAX_SPEED
			jumpCoolDown = false
		end
	end
end)

I see the mistake I made on that assembly velocity bit of code. Thanks!
However, I shouldn’t use runservice for the repeat loop since that would give people with higher fps an advantage.

1 Like