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

How to make the character "dash" after a certain animation plays?

Asked by 8 years ago

I'm not sure why this won't work/if I'm even doing it right.



local tool = script.Parent local speedboost = 1.00 is added local damage = 100 local swingtime = 1 local combowindow = .5 local debris = game:GetService("Debris") local handle = tool:WaitForChild("Handle") local event = tool:WaitForChild("RemoteEvent") local slashsound = handle:WaitForChild("SlashSound") local overheadsound = handle:WaitForChild("OverheadSound") local lungesound = handle:WaitForChild("LungeSound") local lastclick = tick() local combo = 0 local lastclick = tick() local combo = 0 handle.Touched:connect(function(hit) if equipped and character and humanoid and humanoid.Health > 0 and hit and not hit:isDescendantOf(character) then local targethumanoid = hit.Parent:FindFirstChild("Humanoid") hithumanoids = {} if targethumanoid and targethumanoid.Health > 0 and not hithumanoids[targethumanoid] then hithumanoids[targethumanoid] = true for _, v in pairs(targethumanoid:GetChildren()) do if v and v.Name == "creator" then v:remove() end end local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = targethumanoid targethumanoid:TakeDamage(damage * (combo + 1)) end end end) tool.Activated:connect(function() local clickdelta = tick() - lastclick if clickdelta > swingtime then lastclick = tick() hithumanoids = {} if clickdelta < swingtime + combowindow then combo = (combo + 1) % 3 else combo = 0 end if player then if combo == 0 then event:FireClient(player, "RunAnimation", "SlashAnim2" ) slashsound:Play() elseif combo == 1 then event:FireClient(player, "RunAnimation", "ThrustAnim2" ) overheadsound:Play() elseif combo == 2 then event:FireClient(player, "RunAnimation", "OverheadAnim2" ) lungesound:Play() end end end end) function lunge(humanoid, torso) local IdleAnim3 = humanoid:LoadAnimation(ThrustAnim2) if IdleAnim3 then IdleAnim:Play() else Tool.Enabled = true return end local target = humanoid.TargetPoint local direction = (target - torso.Position) * Vector3.new(1, 0, 1) newBV = nil --swordOut() if direction.magnitude > .01 then direction = direction.unit newBV = Instance.new("BodyVelocity") newBV.P = 100000 newBV.maxForce = Vector3.new(newBV.P, 0, newBV.P) newBV.velocity = direction * 50 newBV.Parent = torso torso.CFrame = CFrame.new(torso.Position, target * Vector3.new(1, 0, 1) + Vector3.new(0, torso.Position.Y, 0)) end wait(.75) if newBV ~= nil then newBV:remove() end wait(.5) --swordUp() end tool.Equipped:connect(function() equipped = true lastclick = tick() combo = 0 character = tool.Parent player = game.Players:GetPlayerFromCharacter(character) humanoid = character:FindFirstChild("Humanoid") if humanoid then humanoid.WalkSpeed = humanoid.WalkSpeed * speedboost else character = nil end end) tool.Unequipped:connect(function() equipped = false if humanoid then humanoid.WalkSpeed = humanoid.WalkSpeed / speedboost end character = nil humanoid = nil end)

It would be great if someone could teach me the proper way of inserting the "dash"/lunge function. I tried copying the one from the "Phantom Falchion" gear, but to no avail in terms of successfully merging it into this.

function lunge(humanoid, torso)     
    local holdAnim = humanoid:LoadAnimation(Tool.LungeSlash)
    if holdAnim then 
        holdAnim:Play() 
    else 
        Tool.Enabled = true
        return 
    end
    local target = humanoid.TargetPoint 
    local direction = (target - torso.Position) * Vector3.new(1, 0, 1) 
    newBV = nil 
    --swordOut()
    if direction.magnitude > .01 then            
        direction = direction.unit 
        newBV = Instance.new("BodyVelocity") 
        newBV.P = 100000 
        newBV.maxForce = Vector3.new(newBV.P, 0, newBV.P) 
        newBV.velocity = direction * 50 
        newBV.Parent = torso 
        torso.CFrame = CFrame.new(torso.Position, target * Vector3.new(1, 0, 1) + Vector3.new(0, torso.Position.Y, 0)) 
    end 
    wait(.75)       
    if newBV ~= nil then newBV:remove() end 
    wait(.5) 
    --swordUp()
end 

Answer this question