I want to bring a player towards a part using BodyVelocity when E is held, but when the player actually reaches the part, it keeps going forward forever. I have fixed it once by destroying the BodyVelocity once it reaches, but that's not what I'm after. I'm thinking if it is possible for the player to continue moving towards the part even when it reaches so that the player doesn't just fall to the ground if the part is floating. This is my script so far
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local Part = workspace.Part
local moveSpeed = 50
local UserInputService = game:GetService("UserInputService")
local Direction = (humanoidRootPart.Position - Part.Position).Unit
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
EHeld = true
local bodyVelocity = Instance.new("BodyVelocity", humanoidRootPart)
bodyVelocity.MaxForce = Vector3.new(999999, 999999, 999999)
bodyVelocity.P = 50000
bodyVelocity.Velocity = -Direction * moveSpeed
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
bodyVelocity:Destroy()
end
end)
end
end)

2 comments
Everything works well! But is it possible to make it so that I wouldn't need to jump?
increase the force