Can't recreate sword lunge animation

  1. What do you want to achieve? Keep it simple and clear!
    i’m recreating the linked sword as a local sided script for my game (single player game btw)
  2. What is the issue? Include screenshots / videos if possible!
    the user moves, but the sword doesnt. here’s what i mean:

Normal Linked Sword:
image

My Linked Sword:
image

  1. What solutions have you tried so far?
    couldn’t find any solution

here’s the code:

--// PLAYER VARIABLES \\--

local player = game.Players.LocalPlayer
local character = player.Character

--// TOOL VARIABLES \\--

local tool = script.Parent
local handle = tool.Handle

--// SOUNDS \\--

local slashSound = handle.SwordSlash
local lungeSound = handle.SwordLunge
local equipSound = handle.Unsheath

--// SCRIPTING \\--

local hitboxModule = require(game.ReplicatedFirst.Modules.Hitbox)
local runService = game:GetService("RunService")
local mouse = player:GetMouse()
local active = false

function playAnimation(animation)
	local Anim = Instance.new("StringValue")
	Anim.Name = "toolanim"
	Anim.Value = animation
	Anim.Parent = tool
end

--// ATTACK FUNCTIONS \\--

local equipped = false

function slash()
	task.spawn(function()
		active = true
		playAnimation("Slash")
		slashSound:Play()
		task.wait(0.05)
		for count = 1, 10 do
			task.wait(0.01)
			hitboxModule:CreateHitbox(character, handle.CFrame, Vector3.new(5,5,5), 5)
		end
		task.wait(0.5)
		active = false
	end)
end

function lunge()
	active = true
	hitboxModule:CreateHitbox(character, handle.CFrame, Vector3.new(5,5,5), 5)
	playAnimation("Lunge")
	lungeSound:Play()
	task.wait(0.5)
	active = false
end

local lastRightClick = 0

tool.Enabled = true

function activate(click : string)
	if equipped == true and tool.Enabled == true and active == false then
		if click == "Left" then
			tool.Enabled = false
			slash()
			tool.Enabled = true
		elseif click == "Right" then
			tool.Enabled = false
			
			local attackDelay = runService.Stepped:wait()
			if (attackDelay - lastRightClick < 0.2) then
				lunge()
			end
			lastRightClick = attackDelay
			
			tool.Enabled = true
		end
	end
	
end

tool.Equipped:Connect(function()
	equipped = true
	equipSound:Play()
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

mouse.Button1Down:Connect(function()
	activate("Left")
end)

mouse.Button2Down:Connect(function()
	activate("Right")
end)

In the part of the code where it triggers the lunge, Try rotating the swords grip

As far as i can tell there’s nothing telling the script to play any animation, it just creates a string.

that’s just how old tool animations work, the slash animation uses the same thing and it works fine
also i figured it out, it’s because i have to change the tool grip when the animation plays

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.