Trying to make slide be able to go under 1-2 stud gaps smoothly

Hi,

I’m working on a game that utilizes slides as a important mechanic. I want it so that the player can slide under 1-2 stud gaps smoothly without any problem. Problem is mine can only go under 2.5 studs and sometimes it has problems with 2.5. How do I fix this without changing the slide animation?

2 Stud Gap (gets stuck)

Slide:

local function handleAction(actionName, inputState, _inputObject)
	local Humanoid = Character:FindFirstChild("Humanoid") :: Humanoid

	if actionName == ACTION_SLIDE and inputState == Enum.UserInputState.Begin then
		if isSlide then
			return
		end
		
		if Player.Team ~= Settings.Green then
			return
		end
		
		Character.Humanoid.JumpHeight = 0
		
		isSlide = true
		
		local animator = Humanoid:FindFirstChildWhichIsA("Animator")
		local playAnim = animator:LoadAnimation(Animations.Slide)
		playAnim:Play()
		
		local slide = Instance.new("BodyVelocity")
		slide.MaxForce = Vector3.new(1,0,1) * 15000
		slide.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 100
		slide.Parent = Character.HumanoidRootPart
		
		task.spawn(function()
			PlaySound(Background.Slide, Character.HumanoidRootPart, false)
			
			for count = 1, 8 do
				task.wait(.1)
				slide.Velocity *= .6
			end
			
			Character.Humanoid.JumpHeight = 5
			
			task.wait(0.3)
			
			playAnim:Stop()
			slide:Destroy()
			
			task.wait(1.5)
			isSlide = false
		end)
	end
	
	if actionName == ACTION_SPRINT and inputState == Enum.UserInputState.Begin then
		if Humanoid.WalkSpeed == StarterPlayer.CharacterWalkSpeed then
			Humanoid.WalkSpeed = Settings.Sprint
			
			return
		end
		
		if Humanoid.WalkSpeed ~= StarterPlayer.CharacterWalkSpeed then
			Humanoid.WalkSpeed =  StarterPlayer.CharacterWalkSpeed
			
			return
		end
	end
end

Maybe add a small downward force on the player so it clips into the ground a small amout to past the wall.

That sounds like a bad solution to me. I thought about it and the most efficient solution that worked for me was to make the head cancollide turned off when sliding, so the wall can ignore the head.

I did think of that and was going to say in my reply but i thought that exploteters might exploit it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.