I have been searching through the devforum to find a way to disable the default hand out animation roblox has, i have read posts like this:
But both show how to delete the animation from all tools in the game and i need to delete it from specific tools, can anyone tell me how i can do that?
I may also be wrong about those two posts, if so, please let me know.
Sure. When the tool is equipped get the character, find the Animate child of the character, find the toolnone child of Animate, and find the ToolNoneAnimation child of toolnone. Set the parent of the ToolNoneAnimation to nil (or just store it somewhere else). Then get your animation (I’d recommend storing it as a child of your tool), clone it, then set the clone’s parent to toolnone. When the tool is unequipped, remove the cloned animation and add the original toolnone animation (parented to nil or stored somewhere) to the children of toolnone.
So basically, remove the toolnone, from the player.Character.Animate, clone my own animation inside it and then when the tool is unequipped put it back?
Yep! Remove the children from toolnone, add your own, replace the old ones when the tool is unequipped.
Edit:
It looks like you can also just remove and replace the toolnone StringValue container.
local Players = game:GetService("Players")
local tool = script.Parent
local function newToolNoneAnimation(humanoid)
local newAnimation = Instance.new("Animation")
if humanoid.RigType == Enum.HumanoidRigType.R15 then
--R15 animation
newAnimation.AnimationId = "http://www.roblox.com/asset/?id=507767968"
else
--R6 animation
newAnimation.AnimationId = "http://www.roblox.com/asset/?id=180436148"
end
return newAnimation
end
local oldToolNoneChildren = {}
tool.Equipped:Connect(function()
local character = tool.Parent
local humanoid = character:WaitForChild("Humanoid",5)
if not humanoid then return end
local animate = character:WaitForChild("Animate", 5)
if not animate then return end
local toolNone = animate:WaitForChild("toolnone", 5)
if not toolNone then return end
oldToolNoneChildren = toolNone:GetChildren()
for _, child in ipairs(oldToolNoneChildren) do
child.Parent = nil
end
local newAnimation = newToolNoneAnimation(humanoid)
newAnimation.Parent = toolNone
end)
tool.Unequipped:Connect(function()
local player = Players.LocalPlayer
local character = player.Character
if not character then return end
local animate = character:WaitForChild("Animate", 5)
if not animate then return end
local toolNone = animate:WaitForChild("toolnone", 5)
if not toolNone then return end
for _, child in ipairs(toolNone:GetChildren()) do
child:Destroy()
end
for _, child in ipairs(oldToolNoneChildren) do
child.Parent = toolNone
end
end)
Did this code, i just saw you edited a code in, i’m gonna take a look at it now.
script.Parent.Equipped:Connect(function()
local character = script.Parent.Parent
local animate = character:WaitForChild("Animate")
local toolnone = animate:WaitForChild("toolnone")
local tna = toolnone:WaitForChild("ToolNoneAnimation")
tna.Parent = script.Parent
local animation = script.Parent.Animation:Clone()
animation.Parent = toolnone
end)
script.Parent.Unequipped:Connect(function()
local character = script.Parent.Parent.Character
local animate = character:WaitForChild("Animate")
local toolnone = animate:WaitForChild("toolnone")
local tna = script.Parent:WaitForChild("ToolNoneAnimation")
tna.Parent = toolnone
toolnone:WaitForChild("Animation"):Destroy()
end)
The animation is named ToolNoneAnim (whoops, sorry about that!). You also need to do script.Parent.Parent.Parent.Character to get the character in the unequipped connection.
local tool = script.Parent
script.Parent.Equipped:Connect(function()
local character = tool.Parent
local animate = character:WaitForChild("Animate")
local toolnone = animate:WaitForChild("toolnone")
local tna = toolnone:WaitForChild("ToolNoneAnim")
tna.Parent = tool
local animation = tool:WaitForChild("Animation"):Clone()
animation.Parent = toolnone
end)
script.Parent.Unequipped:Connect(function()
local character = tool.Parent.Parent.Character
local animate = character:WaitForChild("Animate")
local toolnone = animate:WaitForChild("toolnone")
local tna = tool:WaitForChild("ToolNoneAnim")
tna.Parent = toolnone
toolnone:WaitForChild("Animation"):Destroy()
end)