RightVelocity Flinging Player When They Jump

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make a dash system where when the player presses E, they get dashed to the left side. I’m using RightVector for this, and if the player dashes in the air, they get flinged to the left side. Script will be shown below 2.

  2. What is the issue? I am not good with sort of CFrame and RightVector stuff, here is the code I have: (the Torso is a HumanoidRootPart Variable. This is also a part in a LocalScript)

Torso.Velocity += Torso.CFrame.RightVector*100 
  1. What solutions have you tried so far? I tried looking on different topics and found nothing. I also tried BodyVelocity but it dashes me into wrong directions.

I also kinda need a method that doesn’t dash the player instantly or really fast, as that would look kinda weird.

Use linear velocity instead, friction for humanoid is different and not easily controllable.

It’s kind of advanced and I only need a few lines of code for this. Can you find a different method? If it’s not possible, then I might try the one above.

this should work i think

Torso.Velocity = Torso.CFrame.RightVector*100 -- remove "+" from "="

or

local bv = Instance.new("BodyVelocity", rootpart)
bv.Name = "velocity"
bv.MaxForce = Vector3.new(0,math.huge,0)
bv.Velocity = rootpart.CFrame.RightVector*100

it’s still flinging me if i dash in the air…

try this
i made both left and right dash velocities and made the code for you
the velocities dont fling my character at all in this code

(Code goes into StarterCharacterScripts located in StarterPlayer) (The script type is a LocalScript)

local char = script.Parent
local rootpart = char.PrimaryPart

local userinputserv = game:GetService("UserInputService")

local rightdashkey = Enum.KeyCode.E 
local leftdashkey = Enum.KeyCode.Q

local canRightdash = true
local canLeftDash = true

local debris = game:GetService("Debris")

local sec = 1
local rightforce = 50
local leftforce = -50

userinputserv.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	
	if input.KeyCode == rightdashkey and canRightdash then
		if not canLeftDash then return end

		canRightdash = false
		
		local velocity = Instance.new("BodyVelocity", rootpart)
		velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		velocity.Velocity = rootpart.CFrame.RightVector * rightforce
		
		debris:AddItem(velocity, .5)
		
		task.wait(sec)
		canRightdash = true
		
	end
	
end)

userinputserv.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end

	if input.KeyCode == leftdashkey and canLeftDash then
		if not canRightdash then return end
		
		canLeftDash = false

		local velocity = Instance.new("BodyVelocity", rootpart)
		velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		velocity.Velocity = rootpart.CFrame.RightVector * leftforce

		debris:AddItem(velocity, .5)

		task.wait(sec)
		canLeftDash = true

	end

end)

here is a vid of me using it
robloxapp-20221227-1427572.wmv (2.6 MB)

this code works anywhere you go because of cframe btw
hope this helps!

will try this, only problem is i will have to redo the whole script with the “energy” system I have.

1 Like

heres my current code:

--|| SERVICES ||--
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DashEvent = ReplicatedStorage:WaitForChild("DashEvent")

local Character = script.Parent
local Torso = Character.HumanoidRootPart
local Humanoid = Character:WaitForChild("Humanoid")

local Dash = Humanoid:LoadAnimation(ReplicatedStorage.Animations.Dash)

local Properties = {
	-- Velocity = 25,
	-- Duration = 0.5,
	Keybind = Enum.KeyCode.E,
	LastDash = tick(),
	Cooldown = 0.01,
}

UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
	if Input.KeyCode == Properties.Keybind then

		if tick() - Properties.LastDash >= Properties.Cooldown then
			if Character.En.Value >= 1 then
				Properties.LastDash = tick()
				DashEvent:FireServer()
				Torso.Velocity = Torso.CFrame.RightVector*100 -- remove "+" from "="
				game.Players.LocalPlayer.PlayerScripts.En.Value -= 25
			else
				return false
			end
		end
	end
end)

actually i think this is a qucik thing, let me try your idea

it works! but how would i make original player animations stop beuase i have a dash animation and it makes the animation when i dash look a bit weird. if u can’t do this ill still end up marking urs as sollution

do you mind showing me a video of the problem?

sure 1 sec (30 letters 30 letters)

robloxapp-20221227-1427572.wmv (2.6 MB)

i was talking about you in the game not me lol

oh wrong file 1 sec sorryy (30)

robloxapp-20221227-1446518.wmv (1.1 MB)

Did you set any animation priority to your animation? if so, it may be the wrong priority, try using the priority called “Action

If you did not set an animation priority to your animation, then like I said above, use the priority named “Action” and the animation may work without the falling animation overriding it

to set an animation priority, just click the “Set Animation Priority” button when you click the three dots on the right to the name of the animation. it should be below “Create new

i changed the priority by opening animation editor, changing priority to “action”, and publishing it overriding my current dash animation. would that work?

robloxapp-20221227-1456394.wmv (427.2 KB)
also sorry this kinda worked it still looks kinda goofy tho

Did you animate the left leg? (30 letters))

let me chekc (30 letterrrrrrrrrrrrrrrrrrrrrrrrrrrrs)