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
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.
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
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 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)