Hello folks, I’m trying to make a system where your character is in a pose while holding a gun. I managed to make the character in a pose but whenever i try to use animation:Stop() it doesn’t work. I’m unaware of any other method of making the character back to normal so help would be appreciated (The animation is a single frame animation by the way).
script.Parent.hold.OnServerEvent:Connect(function(player,char,gun,tri)
local humanoid = char:FindFirstChild("Humanoid")
local anim = script.Parent.Holder
local holdload = humanoid:LoadAnimation(anim)
if tri == true then
holdload:Play()
else
holdload:Stop(0.1)
end
end)
This is because you are creating a new animation object, so you’re actually stopping the new animation not the old one that was previously playing. To fix this, try storing the same animation somewhere. (under the character would be good)
It’s probably because you’re loading a new animation on the character every time the event is fired. You will have lost the previous animation if you try and use this to stop it as well.
Use a local script to load and unload the animation on the player’s character instead and you will be able to save the animation to a variable.
You are making a new holdload, try use it like here:
Here i define holdload only one time not every time the remote is fired.
repeat wait() until game:IsLoaded()
local humanoid = char:FindFirstChild("Humanoid")
local anim = script.Parent.Holder
local holdload = humanoid:LoadAnimation(anim)
script.Parent.hold.OnServerEvent:Connect(function(player,char,gun,tri)
if tri == true then
holdload:Play()
else
holdload:Stop(0.1)
end
end)