I changed the script to this now:
local part = script.Parent-- Get the part that the player will touch
local RunService = game:GetService("RunService")
part.Touched:Connect(function(otherpart) -- Connect to the part's touched event
local hrp = otherpart.Parent:FindFirstChild("HumanoidRootPart") -- Find the player's HumanoidRootPart
local bodyvelocity = hrp:FindFirstChildWhichIsA("BodyVelocity") -- Check if the player has a body velocity attached
if hrp and not bodyvelocity then
local newvalue = Instance.new("BodyVelocity") -- Attach a body velocity to the player's humanoid root part to give them an upward push
newvalue.Velocity = Vector3.new(0, -25, 0) -- give an upward velocity of 10000 in the Y-axis
newvalue.MaxForce = Vector3.new(10000, 10000, 10000) -- Set the max force to be able to apply to the player's humanoid rootpart
newvalue.P = 5000 -- Set the damping property of the body velocity to 5000
newvalue.Parent = hrp -- Parent the body velocity to the player's humanoid root part
-- Function to be run every render step to check if the player is within 100 studs of the ground
local function onHeartbeat()
if hrp.Position.Y <= 100 then -- Check if the player's humanoid root part is within 100 studs of the ground
hrp.BodyVelocity.Velocity = Vector3.new(0,0,0) -- Set the player's velocity to (0,0,0)
hrp.BodyVelocity.MaxForce = Vector3.new(0,0,0) -- Set the max force to (0,0,0) to stop applying the upward force
newvalue:Destroy() -- Remove the bodyvelocity
RunService:RemoveHeartbeat(onHeartbeat) -- Remove the heartbeat event
end
end
-- Bind the heart beat function to the render step
RunService:BindToRenderStep("slowFall", Enum.RenderPriority.First.Value, onHeartbeat)
end
end)
--This will effectively slow down their fall as they get closer to the ground.
It works, however I have another problem now. I can’t get the new value to get removed/destroyed once the player reaches a certain point. I’m glad I can at least slow the player’s fall though.