Usually I use BodyPosition to apply force. I do something similar to what you mentioned.
ui.InputBegan:Connect(function(Key, Chatting)
if Chatting == false then
if Key.KeyCode == Enum.KeyCode.F then
local bf = Instance.new("BodyPosition")
bf.MaxForce = Vector3.new(0,math.huge,0)
bf.Position = Character.HumanoidRootPart.Position + Vector3.new(0,15,0)
bf.P = 7500
bf.D = 550
bf.Parent = Character.HumanoidRootPart
while Jumped do
wait()
if math.floor(Character.HumanoidRootPart.Position.Y) <= (math.floor(bf.Position.Y) + 2) and math.floor(Character.HumanoidRootPart.Position.Y) >= (math.floor(bf.Position.Y) -2) then
bf:Destroy()
break
end
end
end
end
end)
on this script I create a BodyPosition on the Character.HumanoidRootPart so it moves the entire character. I put the goal 15Y+ from the current position, and then let it run smoothly.
When the position reaches a value that's more than 15 by 2, or less than 15 by 2, it will instantly be destroyed to give momentum to the character and also make it look more smooth.
If you're curious about the functions I used and what they do, I used:
math.floor to turn the value into an absolute value. Example of that would be 20.343434 turned into 20.
1 comment
Pretty sure you can just keep the BodyForce on the player for as long as you like?