I want to make it so when a player starts falling and then touches a part 100 studs from the ground they then start to fall slowly.
I tried using a script one of my friends made when we were working on a different game but it didn’t do what I wanted it to do and I don’t understand it.
I looked here but I only found solutions to other people that included a lot more stuff than I was looking for and didn’t what to get rid of.
I used this script:
local part = script.Parent
local canget = true
part.Touched:Connect(function(otherpart)
local hrp = otherpart.Parent:FindFirstChild("HumanoidRootPart")
local bodyvelocity = hrp:FindFirstChildWhichIsA("BodyVelocity")
if hrp and not bodyvelocity and canget then
local newvalue = Instance.new("BodyVelocity")
newvalue.Velocity = Vector3.new(0,10000,0)
newvalue.MaxForce = Vector3.new(10000,10000,10000)
newvalue.P = 5000
newvalue.Parent = hrp
canget = false
task.wait(0.5)
newvalue:Destroy()
task.wait(0)
canget = true
end
end)
The player is falling from 10000 studs off the ground so they need to slow down a lot in order to not fling all over the place. I don’t know if this is the right script for what I’m doing but it’s the only thing I could think of.
One way that came to mind is to use a RunSerivce.Heartbeat event and wait until the player is within X studs of the ground, then set their AssemblyLinearVelocity to Vector.new(0,0,0), then disconnect the event.
I don’t know how to do that because I am not somebody who knows how to script anything complicated. I only know how to make basic stuff like change transparency when a part is touched or change CanCollide, ect.
This is my solution, It’s basically what Mr ChatGPT said but in script form and with comments so you actually understand whats going on.
local part = script.Parent -- Get the part that the player will touch
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, 10000, 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.
Also you should probably learn to at least do basic scripting just so you can actually understand to a degree and make changes tailored to your game.
When I inputted the script it said Unknown global “RunService”
I have tried to learn how to script and I have to some degree but it’s difficult. I am a lot better at making models and building thing than I am at scripting.
Sorry this script was made really quick so there might be errors. I don’t know anything about your game so you have to make changes yourself. Also, don’t be put off scripting. If you learn in baby steps it’s way easier.
I do partially want to learn how to script a lot of stuff but some of the time I don’t need to know how to do all of that. The game by the way is a dropper. If you don’t know what it is it’s where you fall from a high height and dodge objects. My game has a lobby where there are teleporters where you can teleport to a difficulty for each dropper. The reason I need the player to slow down is because when they reach the bottom they fling all over the place. The part at the bottom teleports the player to the lobby and then the player flings all over the place and sometimes into a teleporter.