Hey there! So recently, I’ve been studying body velocity and stuff and I am trying to make somthing like this:
I am trying to figure out how I can make such a smooth jump like that. I have looked all over the forum and read up on body velocity and body movers, but I am still not exactly sure how I would do this. I tried to implement one of my old weapon trajectory scripts to see if it would work with the player, but it didn’t launch me at all(not surprised lol)
Here is the script I tried:
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if debounce == false then
debounce = true
local char = hit.Parent
local hrp = char:FindFirstChild("HumanoidRootPart")
local target = script.Parent.Parent.End
hrp.Velocity = ((hrp.Position - target.Position).unit * -script.Parent.Parent.Value.Value + Vector3.new(0,50,0))
print("launched")
wait(2)
debounce = false
end
end
end)
There are no errors, it just doesn’t work. I think velocity is deprecated as well.
First of all, there are a number of ways to add velocity to a part (and your character). You can use the body movers (BodyForce or BodyVelocity or BodyPosition). The velocity definitely works too.
In your example, maybe the velocity is too small? Or maybe it’s in the wrong direction (downwards instead of upwards). Try to print the velocity before you assign it and see what happens there?
local vel = ((hrp.Position - target.Position).unit * -script.Parent.Parent.Value.Value + Vector3.new(0,50,0))
print(vel)
hrp.Velocity = vel
There are some other things to note here as well. When running normally humanoids apply all sorts of forces on their own based on their ‘actions’, and if you want smooth physics and forces that are applied properly on your character you might want to look into this:
For example enabling PlatformStand during the Velocity application might help. Not entirely sure though
Wait what? You don’t need to send any remoteEvent.
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if debounce == false then
debounce = true
local char = hit.Parent
local hrp = char:FindFirstChild("HumanoidRootPart")
local target = script.Parent.Parent.End
local vel = ((hrp.Position - target.Position).unit * -script.Parent.Parent.Value.Value + Vector3.new(0,50,0))
print(vel)
local hum = char:FindFirstChild("Humanoid")
hum:ChangeState(Enum.HumanoidStateType.Physics)
hrp.Velocity = vel
print("launched")
wait(2)
debounce = false
end
end
end)
I’ve noticed that you are using velocity, which will not work in the current day as it is not supported anymore. I suggest using body movers. (like what others are suggesting)
The BodyVelocity @Lucarkirb mentioned is basically trying to maintain a given Velocity, therefore you should only keep it alive for about 1 second, and afterwards destroy it. However, even after you destroy it, coming back to my previous comment:
Your humanoid is probably in a state that doesn’t allow for smooth physics conservation, so the velocity that the BodyVelocity applied is instantly interrupted.
Based on my understanding, you are running this in a Server script, right? What would be the problem if you did this in a local Script? I recommend moving your code into a new Local Script under CharacterScripts: StarterCharacterScripts | Roblox Creator Documentation
Careful though as you won’t be able to use: script.parent.Touched , you will need to reference the part within your workspace. So if the name of the part is ‘GivenPart’, you should change your script to:
local debounce = false
game.Workspace.GivenPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == game.Players.LocalPlayer.Name then
if debounce == false then
debounce = true
local char = hit.Parent
local hrp = char:FindFirstChild("HumanoidRootPart")
local target = script.Parent.Parent.End
local vel = ((hrp.Position - target.Position).unit * -script.Parent.Parent.Value.Value + Vector3.new(0,50,0))
print(vel)
local hum = char:FindFirstChild("Humanoid")
hum:ChangeState(Enum.HumanoidStateType.PlatformStanding)
local BV = Instance.new("BodyVelocity",hrp)
BV.Velocity = vel
print("Launched")
wait(0.5) -- adjust accordingly
BV:Destroy()
debounce = false
end
end
end)
PS. I am unfortunately unable to use Roblox Studio atm, therefore I might have made some mistakes, please let me know if there are any errors