#Dashing

1 messages · Page 1 of 1 (latest)

river viper
#
UIS.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or Cooldown then return end

    holdingKeys[input.KeyCode] = true

    if input.KeyCode == Enum.KeyCode.Q then
        if holdingKeys[Enum.KeyCode.W] then
            Key = "Forward"
        elseif holdingKeys[Enum.KeyCode.A] then
            Key = "Left"
        elseif holdingKeys[Enum.KeyCode.S] then
            Key = "Backwards"
        elseif holdingKeys[Enum.KeyCode.D] then
            Key = "Right"
        else
            Key = "None"
        end

        Cooldown = true

        local character = player.Character or player.CharacterAdded:Wait()
        local humanoid = character:WaitForChild("Humanoid")
        local hrp = character:WaitForChild("HumanoidRootPart")

        --[[
        local animator = humanoid:FindFirstChildOfClass("Animator") or humanoid:WaitForChild("Animator")
        local animations = {
            Anim1 = ReplicatedStorage.Animations:WaitForChild("M1"),
            Anim2 = ReplicatedStorage.Animations:WaitForChild("M2"),
            Anim3 = ReplicatedStorage.Animations:WaitForChild("M3"),
            Anim4 = ReplicatedStorage.Animations:WaitForChild("M4")
        }
        local animationToPlay = animations["Anim" .. Anim2]
        if animationToPlay and animationToPlay:IsA("Animation") then
            animator:LoadAnimation(animationToPlay):Play()
        else
            warn("Animation not found or invalid: " .. "Anim" .. Anim2)
        end
        --]]

        -- Fire server with the direction key and current CFrame
        Remote2:FireServer(Key, hrp.CFrame, hrp)

        --[[Anim2 += 1
        if Anim2 > 2 then
            Anim2 = 1
        end

        task.wait(CooldownTime)
        Cooldown = false

        task.delay(1.5, function()
            Anim2 = 1
        end)]]
    end
end)

UIS.InputEnded:Connect(function(input)
    holdingKeys[input.KeyCode] = nil
end)
#

im trying to make front, back and side dashses am i on the right track?

#

my code seems to not be working

#
Remote2.OnServerEvent:Connect(function(player, key, cf, hrp)
    if Busy then return end
    Busy = true

    local combat = Combat.new(0, 5)

    local function Stun(target)
        combat:Stun(target)
    end

    if key == "Forward" then
        KnockBackModule.Knockback(cf, cf.LookVector, 10)
        Stun(hrp)
    elseif key == "Left" then
        KnockBackModule.Knockback(cf, -cf.RightVector, 10)
        Stun(hrp)
    elseif key == "Right" then
        KnockBackModule.Knockback(cf, cf.RightVector, 10)
        Stun(hrp)
    elseif key == "Backwards" then
        KnockBackModule.Knockback(cf, -cf.LookVector, 10)
        Stun(hrp)
    end

    task.delay(1, function()
        Busy = false
    end)
end)
#

this is the server script

#

tell me if i did any silly mistakes cuz im a beginner 😭

cobalt imp
#

why are you handling movements in server

river viper
#

to make it uncheatable?

cobalt imp
#

yeah but you're complicating it yourself

river viper
#

ow so u dont actually need to do it in the server?

#

but what if they cheat

cobalt imp
#

would it matter though

#

people can just report them to your community server

#

whats exactly not working

river viper
#

its not sashing

#

dashing

rigid carbon
cobalt imp
# river viper dashing

try not to pass humanoidrootpart from client to server, use the player argument from the remote event, get the player's character then humanoidrootpart

river viper
#

ok

#

nope not workin

cobalt imp
#

whats the third argument in knockblackmodule.knockback()

river viper
#
function module.Knockback(Char, Direction, Force)


    if not Char or not Char:FindFirstChild("HumanoidRootPart") then return end

    local HRP = Char.HumanoidRootPart
    if HRP:FindFirstChild("RootRigAttachment") then
        HRP.AssemblyLinearVelocity = Vector3.new(HRP.AssemblyLinearVelocity.X, 0, HRP.AssemblyLinearVelocity.Z)
    end

    local attachment = Instance.new("Attachment")
    attachment.Parent = HRP

    local linearVelocity = Instance.new("LinearVelocity")
    linearVelocity.Attachment0 = attachment
    linearVelocity.VectorVelocity = Direction.Unit * Force
    linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
    linearVelocity.MaxForce = math.huge
    linearVelocity.Parent = HRP

    game.Debris:AddItem(linearVelocity, 0.2)
    game.Debris:AddItem(attachment, 0.2)
end
#

force

cobalt imp
#

try increasing it

river viper
#

no

#

nope

#

doesnt work..

cobalt imp
#

is the table storing any enum keys

#

last time i tried doing this and it doesnt work had to use other method

river viper
#

What method u use?

cobalt imp
#

using Enum.Keycode.KEY.Value as index to store the variable in table

still tendon
#

gonna save you alot of lines

river viper
#

dude

#

its dashing

still tendon
#

so?, instead of detecting movement input key presses you could just detect when the dash keybind is pressed

river viper
#

im trying to make like sidedahses

#

i mean like when the player presses the kybind S theygo backwards

still tendon
#

plus what if the player is pressing s and w at the same time

#

oh well, if you don't want to change your code its okay, here is an example, if you ever changed your mind

OnKeyPressed = function(Player)
            local Character:Model = Player.Character
            local Hum = Character.Humanoid
        
            
            local BV = Instance.new("BodyVelocity")
            BV.MaxForce = Vector3.new(50000, 0, 50000)
            if Character.Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
                BV.Velocity = Hum.MoveDirection * 150
            else
                BV.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 150
            end
            BV.Parent = Character.HumanoidRootPart
            
            for i = 0, 5, 1 do
                task.wait(0.1)
                BV.Velocity = BV.Velocity * 0.7
            end
            
            BV:Destroy()
            
            Hum.WalkSpeed = 20
        end,    ```
river viper
#

bruh

#

body velocirty it deprecated

still tendon
river viper
#

ur method is okay

#

but u forgot that i needed to add animartions lol

still tendon
#

just use movedirection to

river viper
#

is there anything i can refer to like if i move to the right and left other than my methods

#

o yea movedirection.X i forgot about that

#

O wait

#

the problem is

#

humanoidMoveDirection is in the world space

#

so that means if i move to the left side of the world space, accodring to logic i will dash fpward but then becuz this is in the worlds space right i will actually trigger the side dash animation

#

wait am i right?

#

o wait nvm i can use vectortoobjectspace lol

#

but i stll cannot use humanoid i will have to use hrp

keen tinsel
cobalt imp
#

would you pay for it

keen tinsel
cerulean sierra
#

If you want a system, you gotta either work for it or pay for it

#

Nothing is free in this world

unborn spade
cerulean sierra