Every time I dash into an object I get flung and sometimes I end up being stuck on the ground for long periods unable to get up:
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local chr = script.Parent.Parent.Parent
local hum = chr:WaitForChild("Humanoid")
local humrp = chr:WaitForChild("HumanoidRootPart")
local Values = chr.Values
statements = {
heavycombo = Values.Combos.HeavyCombo,
stunned = Values.Status.Stunned,
endlag = Values.Status.Endlag,
iframes = Values.Status.IFrames,
ragdolled = Values.Status.Ragdolled,
blocking = Values.Status.Blocking,
attacking = Values.Status.Attacking
}
local RunningAnimation = Instance.new("Animation")
RunningAnimation.AnimationId = "rbxassetid://15992728336"
local Animator = hum:FindFirstChildWhichIsA("Animator")
local Track = Animator:LoadAnimation(RunningAnimation)
Animations = {
["DashRight"] = 'rbxassetid://15991973453';
["DashLeft"] = 'rbxassetid://15991972075';
["DashFront"] = 'rbxassetid://15997962463';
["DashBack"] = 'rbxassetid://15991971069';
}
for i,v in pairs(Animations) do
local Anim = Instance.new("Animation")
Anim.AnimationId = v
Anim = hum:LoadAnimation(Anim)
Animations[i] = Anim
end
config = {
SideSpeed = 50,
BackSpeed = 50,
FrontSpeed = 50,
SideTime = .1,
BackTime = .2,
FrontTime = .3,
CD = 3,
SideCD = 2,
IFrames = .3
}
local dir
local dec
local Front
local Side
local Frontdb = false
local Sidedb = false
local running = false
local dashing = false
function SideDash(dir)
if Sidedb == false then Sidedb = true
dashing = true
if dir == "Left" then
Side = -1
dec = 0
Animations["DashLeft"]:Play()
local DashVelocity = Instance.new("BodyVelocity")
DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
DashVelocity.P = 9e9
DashVelocity.Parent = humrp
delay(config.SideTime, function()
dec = .1
end)
repeat wait()
DashVelocity.Velocity = humrp.CFrame.LookVector * (0 * config.SideSpeed) + humrp.CFrame.RightVector * (Side * config.SideSpeed)
Side += dec
until Side >= 0
DashVelocity:Destroy()
dashing = false
delay(config.SideCD, function()
Sidedb = false
end)
elseif dir == "Right" then
Side = 1
dec = 0
Animations["DashRight"]:Play()
local DashVelocity = Instance.new("BodyVelocity")
DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
DashVelocity.P = 9e9
DashVelocity.Parent = humrp
delay(config.SideTime, function()
dec = .1
end)
repeat wait()
DashVelocity.Velocity = humrp.CFrame.LookVector * (0 * config.SideSpeed) + humrp.CFrame.RightVector * (Side * config.SideSpeed)
Side -= dec
until Side <= 0
DashVelocity:Destroy()
dashing = false
delay(config.SideCD, function()
Sidedb = false
end)
end
end
end
function Dodge()
if Frontdb == false then Frontdb = true
dashing = true
Front = -1
dec = 0
Animations["DashBack"]:Play()
script.RemoteEvent:FireServer(config.IFrames)
local DashVelocity = Instance.new("BodyVelocity")
DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
DashVelocity.P = 9e9
DashVelocity.Parent = humrp
delay(config.BackTime, function()
dec = .1
end)
repeat wait()
DashVelocity.Velocity = humrp.CFrame.LookVector * (Front * config.BackSpeed) + humrp.CFrame.RightVector * (0 * config.BackSpeed)
Front += dec
until Front >= 0
DashVelocity:Destroy()
dashing = false
delay(config.CD, function()
Frontdb = false
end)
end
end
function Run()
if Frontdb == false then Frontdb = true
dashing = true
Front = 1
dec = 0
Animations["DashFront"]:Play()
Track:Play()
local DashVelocity = Instance.new("BodyVelocity")
DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
DashVelocity.P = 9e9
DashVelocity.Parent = humrp
delay(config.FrontTime, function()
dec = 1
end)
repeat wait()
DashVelocity.Velocity = humrp.CFrame.LookVector * (Front * config.FrontSpeed) + humrp.CFrame.RightVector * (0 * config.FrontSpeed)
until dec == 1
DashVelocity:Destroy()
dashing = false
delay(config.CD, function()
Frontdb = false
end)
running = true
if statements.stunned.Value ~= true and
statements.blocking.Value ~= true and
statements.attacking.Value ~= true
then
hum.WalkSpeed = Values.WalkSpeed.Value * 1.25
end
repeat wait()
if UIS:IsKeyDown(Enum.KeyCode.W) and
statements.stunned.Value ~= true and
statements.ragdolled.Value ~= true and
statements.blocking.Value ~= true and
statements.attacking.Value ~= true
then
else
running = false
end
until running == false
Track:Stop()
if statements.stunned.Value ~= true and
statements.blocking.Value ~= true and
statements.attacking.Value ~= true
then
hum.WalkSpeed = Values.WalkSpeed.Value
end
end
end
UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.Q then
if statements.stunned.Value ~= true and
statements.ragdolled.Value ~= true and
statements.blocking.Value ~= true and
statements.attacking.Value ~= true and
dashing ~= true
then
if UIS:IsKeyDown(Enum.KeyCode.A) then
SideDash("Left")
elseif UIS:IsKeyDown(Enum.KeyCode.D) then
SideDash("Right")
elseif UIS:IsKeyDown(Enum.KeyCode.W) then
Run()
elseif UIS:IsKeyDown(Enum.KeyCode.S) then
Dodge()
elseif UIS:IsKeyDown(Enum.KeyCode.Q) then
Dodge()
end
end
end
end)