trying to apply bodyvelocity to make a "charge forward" effect in a 2D environment. it doesn't seem to work; i'm comparing the LowerTorso's Y-orientation -- if it's > 90, it goes one way, and if it's < 90, it goes the other way. can't compare the Vector3 as that's two userdata values. here's what i'm trying, and it's kind of worked before, but it's not working at all now:

local myHumanoid = char:FindFirstChild("Humanoid")
local Fist = char.RapierBlade
local bv
local myTorso = char:FindFirstChild("LowerTorso")
local target = myHumanoid.TargetPoint 
local direction = (target - Fist.Position).unit

UIS.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end
	local keypressed = Input.KeyCode
	if keypressed == Enum.KeyCode[keyDash] and debounce and debounceDash then
		debounce = false
		debounceDash = false
		print(plr.Name..' has pressed the '..keyDash..' key. Yay!')
		local loadanimation2 = char.Humanoid:LoadAnimation(animationDash)
		loadanimation2:Play()
		
		if myTorso.Orientation.Y < 90 then

		bv = Instance.new("BodyVelocity")
		bv.P = 150000
		bv.maxForce = Vector3.new(5000, 5000, 0)
		bv.velocity = Vector3.new(80, 0, 0)
		bv.Parent = myTorso

		myTorso.CFrame = CFrame.new(myTorso.Position, myTorso.Position + direction) 
		
		wait(0.59)
		bv:Remove()
		debounce = true
		wait (.3)
		debounceDash = true
		end
		
		elseif myTorso.Orientation.Y > 90 then
		bv = Instance.new("BodyVelocity")
		bv.P = 150000
		bv.maxForce = Vector3.new(5000, 5000, 0)
		bv.velocity = Vector3.new(-80, 0, 0)
		bv.Parent = myTorso

		myTorso.CFrame = CFrame.new(myTorso.Position, myTorso.Position + direction)
		
		wait(0.59)
		bv:Remove()
		debounce = true
		wait (.3)
		debounceDash = true
		end
	end)

2 comments

0

Any errors, is it a local or server script, at what point does it stop working, can you cut out the bits of code that aren't important, which bits do you believe is causing the errors? Questions need to be more specific so that people answering know what to look for and how they can help. Posting an entire script here is just going to deter people away as they do not want to sift through 50 lines

0

there are no errors in the output. it's a localscript. pressing the "H" key (keyDash) does nothing other than print the message.