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.
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
I tried this, and it doesnāt work. Hereās what I did.
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.
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.