How to make my tool work with animations

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 am attemping to make a tool work with an animation one of my group members made.

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

I am using the animation correctly and it is playing but it only goes a certain distance and ends. Here is a video of the occurance

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

I attempted to look online but no tutorials I can find are helpful by any means,

here is the code

local remoteEvents = game.ReplicatedStorage:WaitForChild("Remotes").Events

local Calculator = require(game.ServerScriptService:WaitForChild("Modules").Calculator)
local DataManager = require(game.ServerScriptService:WaitForChild("Modules").DataManager)
local ShieldInfo = require(game.ServerScriptService:WaitForChild("Modules").Info.ShieldInfo)


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		wait(5)

		local weapon = DataManager:GetData("PlayerStore", "CurrentWeapon", player)

		local clone = game.ReplicatedStorage:WaitForChild("Weapons")["Default Sword"]:Clone()
		clone.Parent = player:WaitForChild("Backpack")

		--local grip = char.RightHand:WaitForChild("RightGrip"):Destroy()

		clone.Activated:Connect(function()
			local Strength = Calculator:CalculateStrength(player)
			local newStrength = DataManager:GetData("PlayerStore", "Strength", player) + Strength
			local ShieldSize = ShieldInfo[DataManager:GetData("PlayerStore", "CurrentShield", player)].size
		
			local Animation = Instance.new("Animation")
			Animation.AnimationId = "rbxassetid://5245704492"
		
			local SwingAnimTrack = player.Character.Humanoid:LoadAnimation(Animation)
			SwingAnimTrack:Play()
		
			wait(.01)
			
			if newStrength > ShieldSize then
				local difference = newStrength - ShieldSize
				newStrength = newStrength  - difference
			end
		
			DataManager:SetData("PlayerStore", "Strength", newStrength, player)
		
			SwingAnimTrack.Stopped:Wait()
		
			Animation:Destroy()
			SwingAnimTrack:Destroy()
		end)
	end)
end)```
1 Like

Ensure your animation priority is set to Action in the Animation Editor, then republish the animation and see if it’s still happening. Also, I’d say you’re better off handling animations on the client, as a side note.

2 Likes

I guess I forgot to do that even though I thought I did. Anyway, thanks for solving this issue :grin: