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!
So i want to stop the animation going back to normal pose roblox
What is the issue? Include screenshots / videos if possible!
so whenever i click an animation on the gui it should end where it should be but then
return back to normal pose like in the screenshot and idk how to stop that
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried to change priority animations nothing work
no solution founded just 1
local frame=script.Parent
local user=game.Players.LocalPlayer
repeat wait() until user.Character local char=user.Character
local humanoid=char:WaitForChild("Humanoid")
local anim
function playanim(id)
if char~=nil and humanoid~=nil then
local id="rbxassetid://"..tostring(id)
local oldanim=char:FindFirstChild("LocalAnimation")
if anim~=nil then
anim:Stop()
end
if oldanim~=nil then
if oldanim.AnimationId==id then
oldanim:Destroy()
return
end
oldanim:Destroy()
end
local animation=Instance.new("Animation",char)
animation.Name="LocalAnimation"
animation.AnimationId=id
anim=humanoid:LoadAnimation(animation)
anim:Play()
end
end
local b1=frame.Button1
b1.MouseButton1Down:connect(function() playanim(b1.AnimID.Value) end)
local b2=frame.Button2
b2.MouseButton1Down:connect(function() playanim(b2.AnimID.Value) end)
local b3=frame.Button3
b3.MouseButton1Down:connect(function() playanim(b3.AnimID.Value) end)
local b4=frame.Button4
b4.MouseButton1Down:connect(function() playanim(b4.AnimID.Value) end)
local b5=frame.Button5
b5.MouseButton1Down:connect(function() playanim(b5.AnimID.Value) end)
local b6=frame.Button6
b6.MouseButton1Down:connect(function() playanim(b6.AnimID.Value) end)
So as you can see here when i press the animation button sabre salute
the animation doesnt stop where it supposed to be
then it return himself back to normal pose
The video i sended when u see the left arm holding down the sabre
its supposed to stop the animation right there
but then it returned himself back to normal pose
Detect if the animation is about to end and stop it with the line i sent you right before the end with very small number (ex. 0.000001)
I found this script and i added the line that stops it:
animationTrack.Stopped:Connect(function()
animationTrack:Play(0, 1, 0) --Will restart the track at the beginning, fadeIn 0 so it immediately has appropriate weight, speed 0, so that it pauses
animationTrack.TimePosition = animationTrack.Length --Set to the last key in the sequence
animationTrack:AdjustSpeed(0)
end)
Oh Just put it in a function and call it right before calling the animation:Play()
local frame=script.Parent
local user=game.Players.LocalPlayer
repeat wait() until user.Character local char=user.Character
local humanoid=char:WaitForChild("Humanoid")
local anim
function stopanim()
for i,v in pairs(user.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
end
function playanim(id)
if char~=nil and humanoid~=nil then
local id="rbxassetid://"..tostring(id)
local oldanim=char:FindFirstChild("LocalAnimation")
if anim~=nil then
anim:Stop()
end
if oldanim~=nil then
if oldanim.AnimationId==id then
oldanim:Destroy()
return
end
oldanim:Destroy()
end
local animation=Instance.new("Animation",char)
animation.Name="LocalAnimation"
animation.AnimationId=id
anim=humanoid:LoadAnimation(animation)
stopanim()
anim:Play()
end
end
local b1=frame.Button1
b1.MouseButton1Down:connect(function() playanim(b1.AnimID.Value) end)
local b2=frame.Button2
b2.MouseButton1Down:connect(function() playanim(b2.AnimID.Value) end)
local b3=frame.Button3
b3.MouseButton1Down:connect(function() playanim(b3.AnimID.Value) end)
local b4=frame.Button4
b4.MouseButton1Down:connect(function() playanim(b4.AnimID.Value) end)
local b5=frame.Button5
b5.MouseButton1Down:connect(function() playanim(b5.AnimID.Value) end)
local b6=frame.Button6
b6.MouseButton1Down:connect(function() playanim(b6.AnimID.Value) end)