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

Making a 2 handed sword swing?

Asked by 8 years ago
Edited by shayner32 8 years ago

I have been looking all over on the internet/youtube/Roblox how to create 2 handed sword swing but I have found no answers. I got closet's to a 2 handed script but it is 1 handed could anyone help me?

--player
player = nil
--save shoulders
RSH, LSH = nil, nil
--grip
GRP = nil
--welds
RW, LW = Instance.new("Weld"), Instance.new("Weld")
--what anim
anim = "none"

--onselected, save shoulders and get player
script.Parent.Equipped:connect(function()
    player = game.Players:playerFromCharacter(script.Parent.Parent)
    local ch = script.Parent.Parent
    RSH = ch.Torso["Right Shoulder"]
    LSH = ch.Torso["Left Shoulder"]
    GRP = ch["Right Arm"].RightGrip
    --
    RSH.Parent = nil
    LSH.Parent = nil
    --
    RW.Part0 = ch.Torso
    RW.C0 = CFrame.new(1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
    RW.C1 = CFrame.new(0, 0.5, 0)
    RW.Part1 = ch["Right Arm"]
    RW.Parent = ch.Torso
    _G.R = RW
    --
    LW.Part0 = ch.Torso
    LW.C0 = CFrame.new(-1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
    LW.C1 = CFrame.new(0, 0.5, 0)
    LW.Part1 = ch["Left Arm"]
    LW.Parent = ch.Torso
    _G.L = LW
    --
    GRP.C0 = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-1, 0, 0)
    --Bring_Arm_Up animation
    for i = 0, 1, 0.05 do
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, -0.5*i)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i)   
        LW.C1 = CFrame.new(-0.3*i, 0.5+1.2*i, 0)
    end
end)

--griptcf = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-math.pi/2+0.5, 0, 0)

script.Parent.Unequipped:connect(function()
    --Bring_Arm_Down animation
    for i = 1, 0, -0.05 do
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, -0.5*i)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i)   
        LW.C1 = CFrame.new(-0.3*i, 0.5+1.2*i, 0)
    end
    RW.Parent = nil
    LW.Parent = nil
    RSH.Parent = player.Character.Torso
    LSH.Parent = player.Character.Torso
end)

function HomeRunHit(part)
    local h = (part.Parent or game):FindFirstChild("Humanoid") --or findfirstchild optimization
    if h then
        h.Parent = nil
    end
end

function HomeRun()
    for i = 0, 1, 0.1 do
        if anim ~= "homerun" then return end
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3+1.2*i, -0.5*i, -0.5+i)
        --R.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.5, -0.5, 0.5)
        LW.C0 = CFrame.new(-1.5+0.5*i, 0.5, -0.5*i) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)    
        --L.C0 = CFrame.new(-1.0, 0.5, -0.5) * CFrame.fromEulerAnglesXYZ(1.7, 0, 1)
    end
    --start homerunhit connection--
    local con = script.Parent.Handle.Touched:connect(HomeRunHit)
    ----------------------------------------
    for i = 0, 1, 0.2 do
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.5, -0.5-1.7*i, 0.5+0.5*i)
        --R.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.5, -2.2, 1)
        LW.C0 = CFrame.new(-1-0.5*i, 0.5, -0.5+0.5*i) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8-1.2*i)    
        LW.C1 = CFrame.new(0, 0.5-i, 0)
        GRP.C0 = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-1-2*i, 0, 0)
    end
    for i = 0, 1, 0.2 do
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.5, -2.2-0.6*i, 1)
    end
    wait(0.1)
    ----end homerun connection---
    con:disconnect()
    --------------------------------------
    for i = 0, 1, 0.1 do
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.5-1.2*i, -2.8+2.8*i, 1-1.5*i)
        --RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7, 0, -0.4+1.2*i)    
        LW.C1 = CFrame.new(0, -0.5+i*2, 0)
        --LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
        GRP.C0 = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-3+2*i, 0, 0)
    end
end

function Whack()
    for i = 0, 1, 0.2 do
        if anim ~= "norm" then return end
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3+i, 0, -0.5+0.5*i)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7-0.25*i, 0, 0.8-0.6*i)  
    end
    for i = 0, 1, 0.25 do
        if anim ~= "norm" then return end
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(2.3-2.5*i, 0, 0)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.45-0.25*i, 0, 0.2)   
        GRP.C0 = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-1-0.5*i, 0, 0)
    end
    --insert camshake and hit nearby people
    for _, p in pairs(game.Players:GetChildren()) do
        if p.Character:FindFirstChild("Torso") then
            if (p.Character.Torso.Position - (script.Parent.Handle.CFrame*CFrame.new(0, -3, 0)).p).magnitude < 10 then
                local s = script.Parent._CamShake:clone()
                s.Disabled = false
                s.Parent = p.Backpack
                if p ~= player then
                    p.Parent = nil
                end
            end
        end
    end
    ------
    for i = 0, 1, 0.2 do
        if anim ~= "norm" then return end
        wait()
        RW.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(-0.2+1.5*i, 0, -0.5*i)
        LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.2+0.5*i, 0, 0.2+0.6*i)   
        GRP.C0 = CFrame.new(0, -1, 0) * CFrame.fromEulerAnglesXYZ(-1.5+0.5*i, 0, 0)
    end
end

local a = false
local co = nil
--OMGHAX mouseclick
local last_click = 0
script.Parent.MouseClick.Changed:connect(function()
    if time() - last_click < 0.3 then
        anim = "homerun"
        last_click = time()
        HomeRun()
    else
        anim = "norm"
        last_click = time()
        Whack()
    end
end)

Any help?

Moderator note: Please enclose Lua code in the Lua block code tag.

0
Animate using the animation plugin roblox provides, it is much easier than programming the players movements connor12260311 383 — 8y
0
I have to animate the sword fighting style's. But I do not know how to do it. @Connor12260311 ZerefDragneelZero 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Use this plugin to help make animations. It is developed by Roblox and this new version works really well.

Edit: For a tutorial go here

Ad

Answer this question