Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Character = script.Parent;
- local Humanoid = Character:WaitForChild("Humanoid");
- local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart");
- local SideGyro = Instance.new("BodyGyro")
- SideGyro.MaxTorque = Vector3.new(3e5,0,3e5)
- SideGyro.P = 5e5
- SideGyro.Parent = HumanoidRootPart
- local RunService = game:GetService('RunService')
- local UserInputService = game:GetService('UserInputService')
- local Dashing = false
- local DashSpeed = 45
- local DoubleTaps = {}
- local Animations = {
- ["DashRight"] = 'rbxassetid://12878249954';
- ["DashLeft"] = 'rbxassetid://12878251537';
- ["DashFront"] = 'rbxassetid://12878253087';
- ["DashBack"] = 'rbxassetid://12878254845';
- }
- for i,v in pairs(Animations) do
- local Anim = Instance.new("Animation")
- Anim.AnimationId = v
- Anim = Humanoid:LoadAnimation(Anim)
- Animations[i] = Anim
- end
- function Dash(Key)
- if Dashing then
- return
- end
- local DashAnim = "Back"
- local Front = -1
- local Side = 0
- if Key == Enum.KeyCode.A then
- Side=-1
- Front = 0
- DashAnim = "Left"
- end
- if Key == Enum.KeyCode.D then
- Side=1
- Front = 0
- DashAnim = "Right"
- end
- if Key == Enum.KeyCode.W then
- Side=0
- Front = 1
- DashAnim = "Front"
- end
- if Key == Enum.KeyCode.S then
- Side=0
- Front = -1
- DashAnim = "Back"
- end
- Dashing = true
- Animations["Dash"..DashAnim]:Play()
- local DashVelocity = Instance.new("BodyVelocity")
- DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
- DashVelocity.P = 9e9
- DashVelocity.Parent = HumanoidRootPart
- DashVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * (Front * DashSpeed) + HumanoidRootPart.CFrame.RightVector * (Side * DashSpeed)
- coroutine.wrap(function()
- task.wait(.1)
- local DashEffect = game.ReplicatedStorage.DustTrail:Clone();
- DashEffect.Parent = workspace;
- if DashAnim == "Left" then
- DashEffect.DustRight:Destroy();
- DashEffect.CFrame = Character["Right Leg"].CFrame * CFrame.new(-1,0,-2);
- else if DashAnim == "Right" then
- DashEffect.DustLeft:Destroy();
- DashEffect.CFrame = Character["Left Leg"].CFrame * CFrame.new(3,2,5);
- else if DashAnim == "Front" then
- DashEffect.DustLeft:Destroy();
- DashEffect.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,-1,3);
- else
- DashEffect.DustLeft:Destroy();
- DashEffect.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,-1,-.5);
- end
- end
- end
- for i,v in pairs(DashEffect:GetDescendants()) do
- if not v:IsA("ParticleEmitter") then continue end
- v:Emit(5);
- end
- game.Debris:AddItem(DashEffect, .5);
- end)()
- repeat wait() DashVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * (Front * DashSpeed) + HumanoidRootPart.CFrame.RightVector * (Side * DashSpeed)
- until not Animations["Dash"..DashAnim].IsPlaying
- Dashing = false
- DashVelocity:Destroy()
- end
- function LoadDoubleTap(Key,Funct)
- DoubleTaps[Key] = tick()-10
- UserInputService.InputBegan:Connect(function(Pressed,Typing)
- if Pressed.KeyCode == Key then
- if (tick() - DoubleTaps[Key]) < .23 then
- Funct(Key)
- else
- DoubleTaps[Key] = tick()
- end
- end
- end)
- end
- LoadDoubleTap(Enum.KeyCode.W,Dash)
- LoadDoubleTap(Enum.KeyCode.A,Dash)
- LoadDoubleTap(Enum.KeyCode.S,Dash)
- LoadDoubleTap(Enum.KeyCode.D,Dash)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement