Hello, I have a question in terms of how to get my character to lunge forward a set amount of studs after performing a certain animation. I'm trying to mimic a certain greatsword's moveset. I have the animations done for it, but I'm stuck on how to get the user to lunge forward when it performs the lunge attack. If the community here was able to help me, that would be very swell; it certainly would help make the sword feel like a greatsword with the weight of it propelling you forward after a lunge.

I'm not quite sure where to fit in the script the bodythrust?

If you were able to leave an explanation on how it works and where to fit it in, that would be very find. I'm using this template for a sword due to inability to script one that would fit the characteristics of the weapon I'm trying to make.

Oh, and one more things; how do I add one more "combo" to it? Say if I were to add 4 animations to the moveset instead of the existing three.

Thank you for reading and possibly helping me get past this problem. If you are interested in the progress or what the swords look like, they can be located at my place.

Script


local tool = script.Parent


local speedboost = 1.00 -- How much speed you gain when you hold the sword, 1.00 means no speed is added
local damage = 100 -- How much damage your sword takes, 100 is a character's full health at default
local swingtime = 1 -- How many seconds until you can swing it again
local combowindow = .5 -- The amount of time at which you have to click again to move on in the combo


local debris = game:GetService("Debris")
local handle = tool:WaitForChild("Handle")
local event = tool:WaitForChild("RemoteEvent")
local slashsound = handle:WaitForChild("SlashSound") --Change SlashSound to the Sound you want it to play in combo 1
local overheadsound = handle:WaitForChild("OverheadSound") --Change OverHeadSound to the Sound you want it to play in combo 2
local lungesound = handle:WaitForChild("LungeSound") --Change LungeSound to the Sound you want it to play in combo 3

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" ) -- Change SlashAnim2 to the animation you want, the name has to be EXACTLY like the one in the tool
				slashsound:Play()
			elseif combo == 1 then
				event:FireClient(player, "RunAnimation", "ThrustAnim2" ) -- Change ThrustAnim2 to the animation you want, the name has to be EXACTLY like the one in the tool
				overheadsound:Play()Play()BodyForce.Force = Vector5.new(1000,0,0)
			elseif combo == 2 then
				event:FireClient(player, "RunAnimation", "OverheadAnim2" ) -- Change OverheadAnim2 to the animation you want, the name has to be EXACTLY like the one in the tool
				lungesound:Play()
			end
		end
    end
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)

2 comments

0

Deeply sorry if you are turned away by the wall of text.

0

Do not worry, take your time.