This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.
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 to stop a loop animation that play when a Tool is equipped !
What is the issue? Include screenshots / videos if possible!
So I got a loop animation that play when the tool is equipped, I used the tool equipped function. Now I want to stop that loop animation, I donât want to use the Tool unequipped function because I want to stop the loop animation with a mouse click (Tool activated function)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The best way I fund is to directly stop the animation from the humanoid. But, since the tool is still equipped the loop animation wonât stop ! basically, I want to know if it is possible to do that or if there is an alternative to Tool equipped function since it do not let me stop the loop animation without the tool unequipped function !
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!
this is the script to play the loop animation when the tool is equipped.
local function WaitForChild(parent, childName)
while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
return parent[childName]
end
local Tool = script.Parent
local BodyAttach = Tool:WaitForChild('BodyAttach')
local Animations = {}
local MyHumanoid
local MyCharacter
local function PlayAnimation(animationName)
if Animations[animationName] then
Animations[animationName]:Play()
end
end
local function StopAnimation(animationName)
if Animations[animationName] then
Animations[animationName]:Stop()
end
end
function OnEquipped(mouse)
MyCharacter = Tool.Parent
MyHumanoid = WaitForChild(MyCharacter, 'Humanoid')
if MyHumanoid then
Animations['IdleAnim'] = MyHumanoid:LoadAnimation(WaitForChild(script, 'IdleAnimation'))
script.ConnectR6D:FireServer(BodyAttach)
end
PlayAnimation('IdleAnim')
end
function OnUnequipped()
script.DisconnectR6D:FireServer()
for animName, _ in pairs(Animations) do
StopAnimation(animName)
end
end
Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
Quick note, Code Review is for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.
While this does essentially work, your topic should go in #help-and-feedback:scripting-support .
Now, to fix the issue, AnimationTracks can have a set weight.
AnimationTracks with higher priority will override those with lower weight.
So, instead of stopping an equipped/âholdingâ animation (if I am understanding your issue correctly), just set the activated animation weight to be higher than your equipped animation weight and it should work!
Sorry for placing my question in the wrong category, I just fix it ! Yes I already override the animation but after that, the loop animation start playing again and Iâm looking to stop it. Let me explain why ! The item is a necklace. When equipped, the equipped/âholdingâ animation start playing (the necklace float on top of the playerâs extended arm) Then to put the necklace around the neck of the player(Leftclick/Activate tool) I override the loop animation. However, when the necklace is no more in the playerâs hand but around his neck, I no longer want the player to extend his empty hand because of that âequipped/Holdingâ looping stupid animation.
Anyways, after a fews days of reserch I find out that I will need to delete the basic roblox backpack and make my own system also because when the tool is no longer equipped it desapear. And I donât want to replicate the item and weld it around the neck because it will not allow the necklace animation to play (it is an animation to add physic to the necklace when affected by wind or external force)
In conclusion, I put this question in how to do something on Roblox applications such as Roblox Studio because if someone with commen sens who read my question and come with any good answer it will be directed to build a backpack system and no where near a script feed back or any override animation.
Iâm open to any advice about building a backpack (Item) system ! (Looking for the best way to do it)
thx for your concern !
Ok, so hereâs a quick code block (as an example)
local tool = script.Parent -- assuming you don't have this already
-- activated code goes here...
tool.Activated:Connect(function()
(reference_to_your_idle_anim):Stop() -- Presuming you have a custom animation.
-- As an alternative you can use tool.RequiresHandle = false if you are not using a custom weld
tool.Handle:BreakJoints() -- Removes welds inside the handle that connects the necklace
tool.Necklace.Parent = tool.Parent -- Moves the necklace's parent to the character so it isn't deleted when we stop the animation
end)
When using this code, your necklace should be in a model named Necklace and all parts should be welded to a Part named âHandleâ.
RequiresHandle can be off while youâre doing this, but you need a manual Weld to connect the handle and the hand.