Player has mini seizure when hitting the ground

  1. What do you want to achieve?
    what im trying to achieve - YouTube
  2. What is the issue?
    dive problems - YouTube
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local char = player.Character or player.CharacterAdded:Wait()
local HumRP = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")

local diving = false
local debounce = false

UIS.InputBegan:Connect(function(input,isTyping)
	local WKeyDown = UIS:IsKeyDown(Enum.KeyCode.W)
	local AKeyDown = UIS:IsKeyDown(Enum.KeyCode.A)
	local SKeyDown = UIS:IsKeyDown(Enum.KeyCode.S)
	local DKeyDown = UIS:IsKeyDown(Enum.KeyCode.D)
	if isTyping then
		return end
	
	if not diving and WKeyDown or AKeyDown or SKeyDown or DKeyDown then
		if input.KeyCode == Enum.KeyCode.E and debounce == false then
			debounce = true
			diving = true
			humanoid.Jump = false
			
			local velocity = HumRP.Velocity
			
			HumRP.Velocity = Vector3.new(velocity.x,2,velocity.z) * 3.5
			
			local dive = game:GetService("RunService").Heartbeat:Connect(function()
				HumRP.CFrame = CFrame.lookAt(HumRP.Position,HumRP.Position + HumRP.Velocity)
			end)
			
			humanoid.PlatformStand = true
			task.wait(.6)
			dive:Disconnect()
			task.wait(1)
			humanoid.PlatformStand = false
			diving = false
			task.wait(3)
			debounce = false
		end
	end
end)

im not really sure what to do

Hey, @Overzealous_Saul just changed line 36 in there and got it to work.

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local char = player.Character or player.CharacterAdded:Wait()
local HumRP = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")

local diving = false
local debounce = false

UIS.InputBegan:Connect(function(input,isTyping)
    local WKeyDown = UIS:IsKeyDown(Enum.KeyCode.W)
    local AKeyDown = UIS:IsKeyDown(Enum.KeyCode.A)
    local SKeyDown = UIS:IsKeyDown(Enum.KeyCode.S)
    local DKeyDown = UIS:IsKeyDown(Enum.KeyCode.D)
    if isTyping then
        return end

    if not diving and WKeyDown or AKeyDown or SKeyDown or DKeyDown then
        if input.KeyCode == Enum.KeyCode.E and debounce == false then
            debounce = true
            diving = true
            humanoid.Jump = false

            local velocity = HumRP.Velocity

            HumRP.Velocity = Vector3.new(velocity.x,2,velocity.z) * 3.5

            local dive = game:GetService("RunService").Heartbeat:Connect(function()
                HumRP.CFrame = CFrame.lookAt(HumRP.Position,HumRP.Position + HumRP.Velocity)
            end)

            humanoid.PlatformStand = true
            task.wait(.6)
            dive:Disconnect()
            task.wait(1)
            HumRP.CFrame = CFrame.new(HumRP.CFrame.X, HumRP.CFrame.Y, HumRP.CFrame.Z)
            humanoid.PlatformStand = false
            diving = false
            task.wait(3)
            debounce = false
        end
    end
end)

Hopefully that solves your issue

ahh thanks for trying but it did not fix the issue

I don’t have the answer to your question/issue, but here are my insights:

local RunService = game:GetService("RunService")					-- 64 bits / or 0 if instantiated already
local UserInputService = game:GetService("UserInputService")		-- 64 bits / or 0 if instantiated already

local char:Model = game.Players.LocalPlayer.Character or
	game.Players.LocalPlayer.CharacterAdded:Wait()					-- 64 bits / thread wait
local HumRP:BasePart = char:WaitForChild("HumanoidRootPart")		-- 64 bits / thread wait
local humanoid:Humanoid = char:WaitForChild("Humanoid")				-- 64 bits / thread wait

local diving = false												-- 64 bits 
local debounce = false												-- 64 bits
-- sum == 256 to 384 bits

UserInputService.InputBegan:Connect(function(input:InputObject, gameProcessedEvent:boolean)	
	if gameProcessedEvent --isTyping // user is interacting with UI, etc
		or diving or debounce -- tooggled when the following evaluates true
		or not UserInputService:IsKeyDown(Enum.KeyCode.W) -- no need to write local variables if those aren't further used
		and not UserInputService:IsKeyDown(Enum.KeyCode.A) 
		and not UserInputService:IsKeyDown(Enum.KeyCode.S) 
		and not UserInputService:IsKeyDown(Enum.KeyCode.D) 
		and not UserInputService:IsKeyDown(Enum.KeyCode.E) 
	then return end
	
	debounce = not debounce
	diving = not diving
	
	local velocity:Vector3 = HumRP.AssemblyLinearVelocity --// velocity is deprecated, this is recommended
		HumRP.AssemblyLinearVelocity = Vector3.new(velocity.X, 2, velocity.Z) * 3.5 -- there's no such lowercase variables
	humanoid.PlatformStand = true
	
	local heartbeat = RunService.Heartbeat:Connect(function()
		HumRP.CFrame = CFrame.lookAt(HumRP.Position,HumRP.Position + HumRP.AssemblyLinearVelocity)	
	end)
	-- the problem with PlatformStand being used here is generally this requires an object to weld to, 
	-- otherwise what happens is the rootpart just no longer collides
	-- and the character ends up in the floor/ground/other objects
	-- this is a problem when also applying linearvelocity or modifying the position, 
	-- because if the character is inside the floor or another object than the other parts that are colliding 
	-- reacts to the physics of the CFrame or physics applied and reacts to the colliding with the other parts
	--- what's desired is getting the character into a right-angle and freezing input

	task.wait(0.6)
	heartbeat:Disconnect()
	HumRP.CFrame = CFrame.new(HumRP.CFrame.Position) --// this just removes the rotation elements of CFrame
	
	task.wait(1)
	debounce = not debounce
	humanoid.PlatformStand = false
	
	task.wait(3)
	diving = not diving	
end)

“The problem with PlatformStand being used here is generally this requires an object to weld to”
would welding something to the players torso fix this?

this actually did fix it, @Rogers_Roblox im gonna mark you as the solution