before you type anything I just want let you know, I know there are some type of other Methods and much more easy like plr.Character.Humanoid.JumpPower = 70
but thats not the point, I want try it as much detailed as I can. So I decided to watch a video but it didnt bring me far as you can see:
I want configure my Jumping because in some engine something like Character.Humanoid.JumpPower doesnt exist. So let me explain to you what I have been trying so far:
I think the main concept wasnt that wrong after watching the Video, can someone help me to make it correctly?:
local Player = game:GetService("Players").LocalPlayer
local Hmrp = Player.Character:WaitForChild("HumanoidRootPart")
local function Main()
local HmrpGravity = Vector3.new(0,-game.Workspace.Gravity,0)
local Velocity = Vector3.new(0,7,0)
local HmrpPosition = Hmrp.Position
local Previoustime = 0
local GetCurrentTime = tick()
while true do
Previoustime = GetCurrentTime
GetCurrentTime = tick()
local dt = GetCurrentTime - Previoustime;
if dt > 0.15 then
dt = 0.15;
end
Hmrp.Position = Hmrp.Position + dt * Hmrp.AssemblyLinearVelocity
Hmrp.AssemblyLinearVelocity = Velocity + HmrpGravity * dt
end
end
First off, you need to call the “Main” function, and you need to yield in the while loop or else you’re gonna crash.
You would need to disable gravity in workspace or anchor your rootpart because we are simulating gravity with our own code and we don’t need the roblox engine to interfere. You don’t want to use “AssemblyLinearVelocity” because it is applied by roblox physics (which we don’t want), and you will need to update the “Velocity” variable instead. You should also change the CFrame of the rootpart instead of the Position.
You code should look something like this:
local Heartbeat = game:GetService("RunService").Heartbeat
local Player = game:GetService("Players").LocalPlayer
local Hmrp = Player.Character:WaitForChild("HumanoidRootPart")
Hmrp.Anchored = true
local function Main()
local HmrpGravity = Vector3.new(0, -game.Workspace.Gravity / 2, 0)
local Velocity = Vector3.new(0, 70, 0)
local HmrpPosition = Hmrp.Position
local Previoustime = 0
local GetCurrentTime = tick()
while true do
Previoustime = GetCurrentTime
GetCurrentTime = tick()
local dt = GetCurrentTime - Previoustime
if dt > 0.15 then
dt = 0.15
end
Hmrp.CFrame = Hmrp.CFrame + Velocity * dt
Velocity = Velocity + HmrpGravity * dt
Heartbeat:Wait()
end
end
Main()
Yes, because gravity. Try changing the initial Velocity to be higher or put a wait(3) at the top of the script so the initial velocity and the gravity is applied a little bit later. The video you linked doesn’t show how to handle collisions so you will have to figure that out on your own. I also recommend that you test this in 2d with screen guis.
I did test it, put the script in StarterCharacterScripts. Like I said before, the video doesn’t show how to handle collisions, or how to bounce the player; all it does is show you how to implement gravity (downward acceleration)…