Help with Animation Script

I am trying to make a script for my tool. The script is going to play 4 animations, 1 being an Idle animations, and 3 being some attack animations. But i have no Idea How to make this.
These are the Few animations I want in the script.

Screen Shot 2022-07-12 at 4.52.11 PM

3 Likes

Right click them and publish to roblox, copy id then insert animation instance put the id in there then load the animation instance to the humanoid’s animator then play it.

I will do that, but How would I make them play With my tool I made with a script.

1 Like

i recommend learning about Motor 6d, not too hard ( will be 100% easy after learning it, and you will be able to animate chars with tools, and more

I’ll try learning that. Though I am just asking for a script.

1 Like

This has nothing to do with what he is asking. He did not ask for Motor 6D, he asked for a script to PLAY the animations he animated.

This category isnt for sharing or giving out scripts, people will help you if you have an issue related with your code.

Then Message me the script if you have one because all im asking for is a script for my tool.

We pretty much know that, I just don’t like when people post things that arent related to what the problem is. I helped him with the beginning of the code. And showed him that his animation priorities were wrong. He needed help scripting the model. Making it animatable. He did not need help with:

Motor 6D

or

Learning how to publish to roblox, or putting it inside a humanoids animator.

1 Like
  1. Read the guidelines (there is nothing related spoon feeding)

  2. Why did he sent these instead of animation instances.
    image

  3. @Moleza is right about motor6d, and its an additional information. Motor6D plays important part in animating things.

I did look at the Motar6D stuff But im not a scripter i don’t know what any of the code means

For the 3 attacks I’m assuming that you’ll be performing the animations systematically so encase a :Play() animation function within a Tool.Activated function (Tool | Roblox Creator Documentation) with a variable to count that number of times the player has swung. E.g. if (swung%3 == 1) do blah blah blah

Whilst for the idle animation, loop the idle animation and enclose it within a Tool.Equipped function (Tool | Roblox Creator Documentation).
End the animation when the Tool.Unequipped function activates. Fairly simple.

As the others have said, Motor6D would be preferable and useful but this is a more simplistic method and would probably be easier to handle for beginners although the practice may be dubious in the eyes of other scripters.

Thanks. You’er the second person who gave me Information that may help me.

there is alot of ways to create some script for animations ( tool, in this case)

i said Motor 6D because you can do whatever you want, if you don’t use it you will have a hard time welding all stuff ( and will be kinda broken, and will look less cool in my opinion )

alright, i rarely give scripts but this can help, the way it works is:

and since i dont know how you plan your system, i’ll give some example ( if you had some idea in mind it would make it easier)

In this one, you will perfom some sort of attack; 0 ~ 4 ( or more )
after a few seconds if you delay too much, the system will reset your Attack streak to 0 ; – optional

*Can adjust based on which Input you are choosing, [ Mouse or Keyboard ]

btw, this is just an example, but this one i made is kinda nice because animations play in order and without any issue ( i tested and fixed everything ), Can adapt to Remote events and many other systems
— Local Script ---- [ Alert ]

local streak = 0 

local Actual_Time = 0 
local Old_Time = 0
local Passed_Time = 0


--Debounces -- Explanation is, without Debounce,
-- you will be able to spam click and play insanely multiple animations
-- of the same attack at once
--that's why i placed Two debounce types just for things

local RS = game:GetService("ReplicatedStorage")

local PlayerAttack = RS:WaitForChild("PlayerAttacking") -- Remote event Placeholder only

local D = false

Atk1 = false, -- M1
Atk2 = false, -- M1 + M1
Atk3 = false, -- M1 + M1 + M1

-- you can adjust anything --

UIS.InputBegan:Connect(function(input, gameProcessed) 

	Actual_Time = time()				
	Old_Time = time()


	PassedTime = Actual_Time - Old_Time


	if streak >= 0 and input.UserInputType == Enum.UserInputType.MouseButton1 then	--Ativar

		if D == false then

			D = true
			
			Actual_Time = time()

			PassedTime = Actual_Time - Old_Time

			if PassedTime < 1 then -- if the time that elapsed is lesser than 1 Second

				streak = streak + 1						
				print"+1 Streak"
			else 		
				streak = 1 -- this is something that i added because the first atk was not working.
				Old_Time = time()
			end

		else if D == true then
				print"CoolDown Active..."
				return
			end
		end				
	end

	if streak == 1 and D == true then  -- if You reached Streak 1 then -- Atk 1
		if Atk1 == true then
			return
		end
		if Atk1 == false then
			Actual_Time = time()
			Old_Time = time()

			PassedTime = Actual_Time - Old_Time
			Atk1 = true 

			plr.Character.Humanoid.WalkSpeed = 0 -- Optional, Stop the char to perfom the attack

			FirstSwing:Play()
			PlayerAttack:FireServer(input.UserInputType) 
			-- sending info to server
			-- Warning- [ This is a remote event, learn about it and you will understand ]


			print"Atk 1"
			print(PassedTime)

			FirstSwing.Stopped:Wait(0) -- waiting the animation to finish

			plr.Character.Humanoid.WalkSpeed = 16

			D = false

			Atk1 = false

			return
		end				
	end

	if streak == 2 and D == true then -- Atk2					
		if Atk2 == true then
			return
		end
		if Atk2 == false then
			Actual_Time = time()
			Old_Time = time()

			PassedTime = Actual_Time - Old_Time
			Atk2= true

			plr.Character.Humanoid.WalkSpeed = 0

			SecondSwingHere:Play()
			PlayerAttack:FireServer(input.UserInputType) -- Sending input to server
			print"Atk 2"

			SecondSwingHere.Stopped:Wait() -- waiting the animation to finish

			plr.Character.Humanoid.WalkSpeed = 16
			D = false	

			Atk2 = false

			return
		end		
	end


	if streak == 3 and D == true then -- Atk 3

		if Atk3 == true then
			return
		end
		if Atk3 == false then
			Actual_Time = time()
			Old_Time = time()

			PassedTime = Actual_Time - Old_Time
			Atk3 = true

			plr.Character.Humanoid.WalkSpeed = 0

			ThirdSwing:Play()
			PlayerAttack:FireServer(input.UserInputType)

			print"Atk 3"

			print(PassedTime)
			ThirdSwing.Stopped:Wait() -- waiting the animation to finish

			plr.Character.Humanoid.WalkSpeed = 16								

			D = false

			Atk3 = false
			streak = 0 -- Reseting the streak ( end of combo )
			return	
		end
	end
end)

i recommend learning a bit more about animations, i can’t really explain too much, this is something that you must learn before you get into, animations are really easy to manipulate, but a single mistake can lead to tedious bug-fixing, i say this because i worked the whole week to create this one without any help, except a single video on yt ( and it was really messy for some reason, he forgot about many details that made me break my head in two )

  1. Never said there was anything related to spoon feeding

  2. He sent them to show what kind of animation instances he was dealing with

  3. Didnt need motor6D