How to make BodyVelocity fling straight?

I want a jump pad to fling a player up and forwards, but I don’t know how to.

Code:

local function jumpPad(hit)
	local hum  = hit.Parent:FindFirstChild('Humanoid')
	
	if hum then
		local plr = plrs:GetPlayerFromCharacter(hit.Parent)
		local char = plr.Character
		local hrp = char.HumanoidRootPart
		
		local bodyVal = hrp:FindFirstChildWhichIsA('BodyVelocity')
		
		if hrp and not bodyVal then
			
			local newBodyVal = Instance.new('BodyVelocity')
			
			newBodyVal.Velocity = Vector3.new(35, 100, -35)
			newBodyVal.MaxForce = Vector3.new(999999999,999999999,999999999)
			newBodyVal.P = 100000
			
			newBodyVal.Parent = hrp

			
			wait(1)
			
			newBodyVal:Destroy()
		end
	end
end

You could use hrp:ApplyImpulse instead of creating a new Instance and assigning properties.

1 Like

If you just want one fling to the humanoid, I would suggest just changing (in script) the AssemblyLinerVelocity of the humanoidrootpart by the following, you can toy with the values accordingly:

On the Y value add 100 and on the Z value add -100.

It will apply a one time velocity to the rootpart.

It will look like:

hrp.AssemblyLinerVelocity = Vector3.new(0, 100, -100)
1 Like

Would you mind editing my script so I could see what that looks like?

Just set the Velocity of the Jump pad to Vector3.yAxis*100 in the script

local debounce = false

local function jumpPad(hit)
    if not debounce then
    debounce = true

	local hum  = hit.Parent:FindFirstChild('Humanoid')
	
	if hum then
		local plr = plrs:GetPlayerFromCharacter(hit.Parent)
		local char = plr.Character
		local hrp = char.HumanoidRootPart

		if hrp then
			
			hrp.AssemblyLinerVelocity = Vector3.new(0, 100, -100)
		end
    end
    debounce = false
end

This doesn’t work for some reason.

Could you please show that in a script?

He spelt Linear Wrong. It’s AssemblyLinearVelocity. Also I think its deprecated, but you should check before you quote me on anything.

I noticed that he spelt linear wrong, changed the spelling and it still didn’t work.

Does it give errors? If it doesn’t try increasing the values.

Sorry there was typo:

local debounce = false

local function jumpPad(hit)
    if not debounce then
    debounce = true

	local hum  = hit.Parent:FindFirstChild('Humanoid')
	
	if hum then
		local plr = plrs:GetPlayerFromCharacter(hit.Parent)
		local char = plr.Character
		local hrp = char.HumanoidRootPart

		if hrp then
			
			hrp.AssemblyLinearVelocity = Vector3.new(0, 100, -100)
		end
    end
    debounce = false
end

I suggest using LookVector to get “true forward” because if they are rotated they may fling to the left or right.

Good point, i was mobile and rushed it out.

I really hate writing and distributing deprecated code, but the AssemblyLinearVelocity was just way too inconsistent. This was the only solution I could think of.

local ds = game:GetService("Debris")
local debounce = {}

local distance = 25
local height = 25

local function jumpPad(hit)
	local hum  = hit.Parent:FindFirstChild('Humanoid')
	if hum and not table.find(debounce, hum) then
		table.insert(debounce, hum)

		if hum then
			local char = hit.Parent
			local hrp = char.HumanoidRootPart
			local bp = Instance.new("BodyPosition")
			bp.Position = script.Parent.Position+script.Parent.CFrame.LookVector*distance+Vector3.new(0,height,0)
			bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
			bp.Parent = hrp
			bp.D = 1
			bp.P = 50
			ds:AddItem(bp, 0.1)
		end
		table.remove(debounce, table.find(debounce, hum))
	end
end

script.Parent.Touched:Connect(jumpPad)
1 Like

Your code flung me to the left instead of straight up and slightly forward.

You have to find “true forward”. Add a decal to the part and change the face to “front”, it will tell you what direction that is.