Dive Script Not Working

Dive Script Not Working

  1. What do you want to achieve? Keep it simple and clear!

I want to make a Dive Script so for whenever a player presses “E” on their keyboard they will dive.

  1. What is the issue? Include screenshots / videos if possible!

It doesn’t dive me forwards instead my character just falls down when I press “E”.

Here I have a video of my problem.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried different ways such as animations & modifying the humanoidrootpart’s CFrame.

I searched Youtube & the Dev Forum for any help with my issue and couldn’t find what I was looking for.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Here is what my code looks like

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(inp)
	
if inp.KeyCode == Enum.KeyCode.E then

		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame =
			game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame  * CFrame.Angles(math.rad(-50),0,0)
		end
	end)

Any kind of help will be appreciated.

The script is fine, the NPC it only needs a little push, in this case it will be equal to half its height


LocalScript:

local Player = game:GetService("Players").LocalPlayer
local Character = (Player.Character or Player.CharacterAdded:Wait())

local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input, Chat)
	if Input.KeyCode ~= Enum.KeyCode.E or Chat then	return	end
	
	local CF, Size = Character:GetBoundingBox()
	Character:PivotTo(CF * CFrame.new(0, 0, -Size.Y/2) * CFrame.Angles(math.rad(-50),0,0))
end)
1 Like
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(inp)
	
if inp.KeyCode == Enum.KeyCode.E then

		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame =
			game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame  * CFrame.Angles(math.rad(-50),0,0)
            game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector * 5 -- Adjust this to make it more or less pushy
		end
	end)