Hello, I’m new to animating on Roblox and I’m pretty trash at it. I’ve created this simple hold animation for one of my weapons in my game. When I try it out in my game, yes it does play the animation. But it just ends like right after, how can I get the animation to stay there? This is my simple animation script and a video. However I don’t think the script is the problem.
LocalScript inside Tool
local id = "5610784952"
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.Events.GunAnimate:FireServer(id)
end)
script.Parent.Unequipped:Connect(function()
game.ReplicatedStorage.Events.StopGunAnimate:FireServer(id)
end)
ServerScript in ServerScriptService
local events = game.ReplicatedStorage.Events
events.GunAnimate.OnServerEvent:Connect(function(player, animationId)
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationId
local loadAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
loadAnimation:Play()
events.StopGunAnimate.OnServerEvent:Connect(function()
animation:Destroy()
end)
end)
And here’s a video:
Also how would I stop the gun from being sideways? Sorry I’m a noob at this
Did you enable “Toggle Looping Animation” in the animation editor? It’s a little button next to the play animation icons. This will ensure your animation plays continually until it is stopped. As for the gun being sideways, you could try some tool grip editor plugins if it is a tool.
You’ll want to make sure that the animation is looped. Import it back into the Animation Editor and set Looped to true (there’s a button in the topbar of the editor, should be a circle with a play button in the middle iirc). You should also set your Animation Priority accordingly (under File I believe)
Call :Stop() on the animation before destroying it. Also, as @amadeupworld2 said, definitely animate it from a localscript. Your animations will replicate to other clients.
you need to call :Stop() on loadAnimation, not Animation. loadAnimation is an AnimationTrack, which :Stop() is a part of. Animation is simply the animation object, which itself is not being played. loadAnimation is the actual AnimationTrack being played.