I am trying to make this script through the magnitude of the humanoidrootpart of the player instead of userinput. (I believe adding specific keyboard controls are inefficient since I want this script to work for all roblox platform controls like xbox and mobile). different platforms have different controls.
What I am trying to do. Something like this, (A quote from reddit.com)
" **When I press the jump button, I set my vertical speed to a negative value. Then I check to see if the jump button is being held. --Again, I'm using magnitude to trigger jump not UserInput, it should not matter which "jump button" you are pressing on different platforms.-- If the jump button is not being held, and our vertical speed is negative (means we're still going up), I divide the vertical speed by 1.5 every step. This makes it so you stop going up when you release the jump button, but it's not a completely abrupt stop, so it looks more natural."
** Here is my cruddy attempt which doesn't work correctly. I tried using gravity and jumpPower but it still a no go. Please help me with this please?!
local humanoid = script.Parent
local humanoidrootpart = humanoid.Parent:WaitForChild("HumanoidRootPart")
game:GetService( "RunService" ).Heartbeat:connect( function()
if humanoidrootpart.Velocity.Magnitude > 1 then
humanoid.JumpPower = humanoid.Power + 1
game.WorkSpace.Gravity = game.WorkSpace.Gravity - 1
else
game.WorkSpace.Gravity = 900 -- Default Gravity
humanoid.JumpPower = 75 -- Default Jump Power
end
end)
