How do I bring the player to the ground (raycast)?

So im making a fighting game right now based on atla. It has some similarities to a battlegrounds game, but make it fun.

Currently, i’m trying to make an aerial that will bring the player to the ground. I already have found the ground below the player (if there is any) through raycast, and found the instance. But, i need a way to move the player to the ground in a way that i can control the speed. I also want it to end once the player is grounded.

I’d appreciate any help

You could get the direction of the players HRP relative to the position then use linear velocity to drag them there. I think this should work? And you can control speed

1 Like

could you show a code sample? i’m not sure how to go about it

I’m not that active on here mb for the wait… Anyway, I think it might be better to just lerp their CFrame to the position.

Here’s a function that would get the player to a specific position:

local function Banana(HRP:BasePart, GoalPos:Vector3, InfoTween:TweenInfo)
	local StartCFrame = HRP.CFrame
	local EndCFrame = CFrame.new(GoalPos)
	
	local startTime = os.clock()
	
	local Var = 0
	local Elapsed = 0
	
	HRP.Anchored = true
	repeat
		Elapsed = os.clock() - startTime
		Var = math.min(Elapsed / InfoTween.Time, 1)
		
		local Alpha = game:GetService("TweenService"):GetValue(Var, InfoTween.EasingStyle, InfoTween.EasingDirection)
		HRP.CFrame = StartCFrame:Lerp(EndCFrame, Alpha)
		
		task.wait() 
	until Var >= 1
	
	HRP.Anchored = false
end

Passing in the player’s humanoid root part and tween info to the function will move the player to the desired position. “What about controlling speed?” Lower time = same distance, more velocity so it would move faster. If you want the function to take in velocity instead of time or the method doesn’t fit what you want then lmk

Threw in the bonus of tweens because I think you don’t want it to feel boring