Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would you change the player's fall speed?

Asked by 7 years ago
Edited 7 years ago

Hi, I was trying to make it so that when the player is make it so that the player's jump height would stay the same, but if they press and hold space while midair, they would have a lighter fall aka reach the ground slower. This is what I have so far client

        elseif inputObject.KeyCode == Enum.KeyCode.Space then
            if player.Character.Humanoid.Jump == true then
                floating:FireServer("start")
            end
        end
    end)
        UIS.InputEnded:connect(function(inputObject)
            if inputObject.KeyCode == Enum.KeyCode.Space then
                floating:FireServer("stop")
            end
        end)

server

floatingevent.OnServerEvent:connect(function(player,startorstop)
    if script.Parent.Parent:FindFirstChild("Humanoid").Torso:FindFirstChild("floater") then
        floater = script.Parent.Parent:FindFirstChild("Humanoid").Torso:FindFirstChild("floater")
    else
        floater = Instance.new("BodyForce", script.Parent.Parent:FindFirstChild("Humanoid").Torso)
        floater.Name = "floater"
    end
    if startorstop == "start" then
        floater.Force = Vector3.new(0,game.Workspace.Gravity,0) * script.Parent.Parent:FindFirstChild("Humanoid").Torso:GetMass()* 2.5
    end
    if startorstop == "stop" then
        floater.Force = Vector3.new(0,0,0)
    end
    script.Parent.Parent:FindFirstChild("Humanoid").FreeFalling:connect(function()
        floater = script.Parent.Parent:FindFirstChild("Humanoid").Torso:FindFirstChild("floater")
        floater.Force = Vector3.new(0,game.Workspace.Gravity,0) * script.Parent.Parent:FindFirstChild("Humanoid").Torso:GetMass()* 2.5
    end)
end)

The problem with the script is that it alters the player's jump height and not the player's fall speed.

0
maybe try adding a bodyforce in the player when you hold space Paldi 109 — 7y
0
Try to add "Gravity" I seen this on the Roblox Wiki before, : http://wiki.roblox.com/index.php?title=Gravity They even have an example script as well! PumpedRedfalconPE 17 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Create a BodyForce only when the character's HumanoidStateType is Enum.HumanoidStateType.Freefall, then delete it when it gets changed to anything else.

Also, you can add the capability you are talking about by changing the body force's Force whenever the space button is pressed using ContextActionService.

local character = player.Character -- the character
local humanoid = character.Humanoid -- the humanoid of the character

local function createBodyForce(character)
    -- function to make a body force here
    -- also have a function here to "listen" for a space push/hold. 
    -- pseudocode:
    if space held or space pushed then
        bodyForce.Force = some non-zero Vector3
    else
        bodyForce.Force = Vector3.new(0, 0, 0)
    end
end

local function destroyBodyForce(character)
    -- function to destroy a body force here
end

humanoid.StateChanged:Connect(function(old, new)
    if new == Enum.HumanoidStateType.Freefall then
        createBodyForce(character)
    else
        destroyBodyForce(character)
    end
end)
Ad

Answer this question