I need help with my dash script

I have a dashing script and this line of code
HRP.CFrame = CFrame.New (RollDirectiondTRollMult) * HRP.CFrame
leads to this number 0, -3.40282347e+38, 0 * 44. I don’t know how to fix that

wait(1)
local Movement = {
	["Sprint"] = function(Player, Params)
		
	end,
	["Dash"] = function(Player, Params, UserInput)
		local Character = Player.Character or Player.CharacterAdded:Wait()
		local HRP = Character:WaitForChild("HumanoidRootPart")
		local humanoid = Character:WaitForChild("Humanoid")
		local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
		Roll.Priority = Enum.AnimationPriority.Action
		local Debounce = false
		local RollStartTime = 0
		local RollDirection = Vector3.new()
		local RollMult = 15/Roll.Length

		Debounce = true

		if Debounce then

			RollStartTime = tick()
			local dirVec = HRP.CFrame.LookVector
			RollDirection =  (dirVec*Vector3.new(1,0,1)).unit

			local LastBeat = tick()
			game:GetService("RunService").Heartbeat:Connect(function()
				local dT = tick()-LastBeat
				LastBeat = tick()

				if tick()-RollStartTime < .75 then
					HRP.CFrame = CFrame.new(RollDirection*dT*RollMult) * HRP.CFrame
					print(HRP.CFrame)
				end
			end) 
		end
		Debounce = false
	end,
}

return Movement

this is the whole script

1 Like

Instead of CFraming the HumanoidRootPart ( Which leads to the issue you just had ), apply Velocity to the HumanoidRootPart.

wait(1)
local Movement = {
	["Sprint"] = function(Player, Params)
		
	end,
	["Dash"] = function(Player, Params, UserInput)
		local Character = Player.Character or Player.CharacterAdded:Wait()
		local HRP = Character:WaitForChild("HumanoidRootPart")
		local humanoid = Character:WaitForChild("Humanoid")
		local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
		Roll.Priority = Enum.AnimationPriority.Action
		local Debounce = false
		local RollStartTime = 0
		local RollDirection = Vector3.new()
		local RollMult = 15/Roll.Length + 500

		Debounce = true

		if Debounce then
			Roll:Play()
			RollStartTime = tick()
			local dirVec = HRP.CFrame.LookVector
			RollDirection =  (dirVec*Vector3.new(1,0,1)).unit

			local bodyVelocity = Instance.new("BodyVelocity")
			bodyVelocity.Velocity = RollDirection * RollMult 
			bodyVelocity.MaxForce = Vector3.new(10000,0,10000)
			bodyVelocity.Parent = HRP
			
			wait(Roll.Length)
			
			bodyVelocity:Destroy()
		end
		Debounce = false
	end,
}

return Movement

This is why I don’t use Velocity.

1 Like

That’s because you’re using a deprecated BodyMover, use the basic Velocity property.

2 Likes

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