Issue with sword script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a sword that can go into combos and loop.

  1. What is the issue? Include screenshots / videos if possible!

The code is stopping before the animations play. No errors in output.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve added prints to pinpoint where it’s stopping. I’ve also tried different ways of running the animations.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Activation script:

local function activated()
	if isswinging == false then
		isswinging = true

		if swingindex >= 3 then
			swingindex = 1
		else
			swingindex += 1
		end

		print(swingindex)

		for i, v in pairs(swingsloaded) do
			print("for loop")
			if i == swingindex then
				print("i is index")
				v:Play()
				print(v.Name)
				print("played")

				v.Ended:Connect(function()
					isswinging = false
				end)
			end
		end

		previousindex = swingindex

		task.wait(2.5)

		if swingindex == previousindex then
			swingindex = 0
		end
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Could you explain more on the “code stopping?”


I think you should get the time of activation and determine if it did change then reset.


The Ended event in an AnimationTrack fires after the AnimationTrack finishes, including fading out.
I think Stopped is more appropriate here.

1 Like

Got it working. I needed to recall the table that holds the animations because it was holding the unloaded animations. I also messed up with one of the animations, realized it was set to “Core” instead of Action2.

1 Like

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