You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want my gun idle animation to work
What is the issue? Include screenshots / videos if possible!
in the animation editor it works fine but when testing the game nothing works
when testing the game:
Animation Editor:
What solutions have you tried so far? youtube, devforums,Developer Hub, RoDevs,Scripting Helpers.
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!
local Tool = script.Parent
local Animation = Tool.Idle
Tool.Activated:Connect(function()
local Character = Tool.Parent
local Humanoid = Character.Humanoid
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end)
anyway, if this is in the wrong category tell me please cause im not sure if its the script or the animation.
I believe i see the problem your using tool.Activated which fires when a player clicks the Left mouse button while the tool is Equipped use tool.Equipped
Did you set the Animation to loop?
Also im pretty sure something about :LoadAnimation() was depreciated recently that could be the cause of the problem ill see if i can find it
ocal function playAnimationFromServer(character, animation)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
-- need to use animation object for server access
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
return animationTrack
end
end
end
“need to use animation object for server access” Animation object? I’m sorry if this answer is really obvious its really late and this is new stuff and i’ve been looking for a clue for multiple hours.
dont go instantly to rescripting your stuff :LoadAnimation() still works there are just better alternatives at the moment
Try checking if the Animation has an Id
after a bit of testing i think :LoadAnimation() doesnt work anymore i dont know why
But try looking at the Animator class
i havent had to work with animators so im just as in the dark as you
Edit: For some reason now its working no changes just started working
Tool.Equipped:Connect(function()
local Human = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
if not Human then
Human = Tool.Parent:WaitForChild("Humanoid")
else
local AnimationTrack = Human:LoadAnimation(Animation)
AnimationTrank:Play()
end
end)
It seems to me like you’re animating a gun rig, but never attaching it to the character at run-time… I’m pretty sure you need to attach BodyAttach to your character somehow, I don’t know how your rig is meant to be used, but you definitely need to do this, also - since you’re using a tool, you need to remove the RightGrip weld in the character’s RightHand!!
is there any errors? also it may be because your using the activated function, not the equipped function, activated is fired when you click while holding the tool and equipped is fired when you equip the tool