Tool holding not working

So I have some code that should make it so when the player spawns in / respawns, they spawn with a tool in their hand with a custom holding animation script.

Problem: The holding animation does not visibly play upon spawning. However, the gun goes in the hand.

plrs.PlayerAdded:Connect(function(plr)
	local char
	plr.CharacterAdded:Connect(function(newChar)
		char = newChar
		local hum = char:WaitForChild("Humanoid")
		local animator : Animator = hum:WaitForChild("Animator")

		local newRifle = rifleModel:Clone()
		newRifle.Parent = char
		
		local parts = newRifle.Parts
		
		local motor = parts.Motor
		motor.Part0 = char:WaitForChild("Right Arm")
		
		local track : AnimationTrack = animator:LoadAnimation(parts.holdAnim)
		track:Play()
		track.Looped = true
		print(track.IsPlaying)
		task.wait(1)
		print(track.IsPlaying)
	end)
	
end)

basically when the character arrives i put the tool in his hand which works

but my custom holding animation doesnt

also, the print statements for track.IsPlaying both print true, itā€™s just that ingame my character isnā€™t using the animation

Notes:

  • Game settings and animation are both r6 so itā€™s not that
  • ā€œMotorā€ is a motor 6D
  • The animation priority was set to ā€˜Idleā€™ inside the animation editor
  • the rifleModel is located in serverstorage and this is a server side script in server script service

Thanks to anyone who read the entire thing and is about to help me.

if you need any more info plz comment below

1 Like

Itā€™s likely because you need to replace the toolnone roblox animation with your own. You can do this by playing the game, going to your character, finding ā€œAnimateā€ localscript, putting it in starterplayerscripts, going in the code and replacing the toolnone ID with your own. Also, make sure to look inside the Animate script to find the toolnone ID thing there too which you also need to replace

2 Likes

I tried this, and it doesnā€™t work. Hereā€™s what I did.

  1. I went into the Animate script and replaced the toolnone id with my own id. I also tried to change the heading to http://wwwā€¦etc but that didnā€™t work either.

  2. I found the toolnone string value inside of the animate script, and changed its Animationā€™s animId to my own Id.

None of these worked.

Also sorry for the confusion, what I meant was my ā€œtoolā€ is actually a model and when the character spawns i shove the model in their hands, (itā€™s a weapon)

Edit: @ConnectedNow I realized the issue. Even though I waited for the character to be added, I guess it was so early into loading the animation wouldnt play. I found this when I decided to add a 1 second wait statement above the code that plays the animation, and it worked! Later Iā€™ll add a loading screen and use that.

1 Like