Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made a dash scripting, for some odd reason it doesn't work, anyone know what I'm doing wrong?

Asked by 5 years ago
Edited 5 years ago
DoubleW = false

UserInputService.InputBegan:Connect(function(Input, Touched)
    if not Touched then
        if Input.KeyCode == Enum.KeyCode.W and Enabled == true and Player.Backpack.Attributes.Armed.Value == true then
            local ray = Ray.new(HRP.CFrame.p, (HRP.CFrame * CFrame.new(0, -4, 0).p - HRP.CFrame.p).unit * 3)
            local ignore = {workspace.Map}
            local hit, position, normal = workspace:FindPartOnRayWithWhitelist(ray, ignore)
            if DoubleW == false then
                DoubleW = true
                spawn(function()
                    wait(0.2)
                    DoubleW = false
                end)
            elseif DoubleW == true and hit then
                local Smoke = Assets.Particles.Smoke2:Clone()
                Smoke.Parent = Character.LeftFoot
                Anims.DashFoward:Play()
                local BodyVelocity = Instance.new("BodyVelocity", HRP)
                BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
                BodyVelocity.Velocity = HRP.CFrame.lookVector * 50
                game.Debris:AddItem(BodyVelocity, 0.2)
                Enabled = false
                spawn(function()
                    wait(0.1)
                    Smoke.Enbabled = false
                    wait(0.1)
                    game.Debris:AddItem(Smoke, 1)
                    Anims.DashFoward:Stop()
                    wait(0.6)
                    Enabled = true
                end)
            end
        end
    end
end)

DoubleS = false

UserInputService.InputBegan:Connect(function(Input, Touched)
    if not Touched then
        if Input.KeyCode == Enum.KeyCode.S and Enabled == true and Player.Backpack.Attributes.Armed.Value == true then
            local ray = Ray.new(HRP.CFrame.p, (HRP.CFrame * CFrame.new(0, -4, 0).p - HRP.CFrame.p).unit * 3)
            local ignore = {workspace.Map}
            local hit, position, normal = workspace:FindPartOnRayWithWhitelist(ray, ignore)
            if DoubleS == false and hit then
                spawn(function()
                    wait(0.2)
                    DoubleS = false
                end)
            elseif DoubleS == true and hit then
                local Smoke2 = Assets.Particles.Smoke2:Clone()
                Smoke2.Parent = Character.LeftFoot
                Anims.DashBackward:Play()
                local BodyVelocity = Instance.new("BodyVelocity", HRP)
                BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
                BodyVelocity.Velocity = HRP.CFrame.lookVector * - 50
                game.Debris:AddItem(BodyVelocity, 0.2)
                Enabled = false
                spawn(function()
                    wait(0.1)
                    Smoke2.Enabled = false
                    wait(0.1)
                    game.Debris:AddItem(Smoke2, 1)
                    Anims.DashBackward:Stop()
                    wait(0.6)
                    Enabled = true
                end)
            end
        end
    end
end)

DoubleA = false

UserInputService.InputBegan:Connect(function(Input, Touched)
    if not Touched then
        if Input.KeyCode == Enum.KeyCode.A and Enabled == true and Player.Backpack.Attributes.Armed.Value == true then
            local ray = Ray.new(HRP.CFrame.p, (HRP.CFrame * CFrame.new(0, -4, 0).p - HRP.CFrame.p).unit * 3)
            local ignore = {workspace.Map}
            local hit, position, normal = workspace:FindPartOnRayWithWhitelist(ray, ignore)
            if DoubleA == false and hit then
                spawn(function()
                    wait(0.2)
                    DoubleA = false
                end)
                DoubleA = true
            elseif DoubleA == true and hit then
                local Smoke2 = Assets.Particles.Smoke2:Clone()
                Smoke2.Parent = Character.LeftFoot
                Anims.Dash1:Play()
                local BodyVelocity = Instance.new("BodyVelocity", HRP)
                BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
                BodyVelocity.Velocity = (HRP.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector * 50
                game.Debris:AddItem(BodyVelocity, 0.2)
                Enabled = false
                spawn(function()
                    wait(0.1)
                    Smoke2.Enabled = false
                    wait(0.1)
                    game.Debris:AddItem(Smoke2, 1)
                    Anims.Dash1:Stop()
                    wait(0.6)
                    Enabled = true
                end)
            end
        end
    end
end)

DoubleD = false

UserInputService.InputBegan:Connect(function(Input, Touched)
    if not Touched then
        if Input.KeyCode == Enum.KeyCode.D and Enabled == true and Player.Backpack.Attributes.Armed.Value == true then
            local ray = Ray.new(HRP.CFrame.p, (HRP.CFrame * CFrame.new(0, -4, 0).p - HRP.CFrame.p).unit * 3)
            local ignore = {workspace.Map}
            local hit, position, normal = workspace:FindPartOnRayWithWhitelist(ray, ignore)
            if DoubleD == false and hit then
                spawn(function()
                    wait(0.2)
                    DoubleD = false
                end)
            elseif DoubleD == true and hit then
                local Smoke2 = Assets.Particles.Smoke2:Clone()
                Smoke2.Parent = Character.RightFoot
                Anims.Dash2:Play()
                local BodyVelocity = Instance.new("BodyVelocity", HRP)
                BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
                BodyVelocity.Velocity = (HRP.CFrame * CFrame.Angles(0, math.rad(-90), 0)).lookVector * 50
                game.Debris:AddItem(BodyVelocity, 0.2)
                Enabled = false
                spawn(function()
                    wait(0.1)
                    Smoke2.Enabled = false
                    wait(0.1)
                    game.Debris:AddItem(Smoke2, 1)
                    Anims.Dash2:Stop()
                    wait(0.6)
                    Enabled = true
                end)
            end
        end
    end
end)
1
Is there an error? It's a lot of code for someone to blindly go through it DanzLua 2879 — 5y
0
wow thats a long code OBenjOne 190 — 5y
1
I just used the find on page command and can't find where you set BodyVelocity.Parent, not sure whether this is your problem but I have forgoten to set a BodyVelocity's parent before OBenjOne 190 — 5y
1
It is just an idea but it would explain why your script does not work and provides no errors OBenjOne 190 — 5y
View all comments (2 more)
1
I dont know if this would help, but i think it would be best to put the code in different scripts, so its more managable. fighterkirbyzx 102 — 5y
0
Legit I've tried everything, and it's just not working. I don't know what I'm doing wrong for it not to work. 44_PixeIs 28 — 5y

Answer this question