#how do I code a script that plays a different animation to hold a tool?
1 messages · Page 1 of 1 (latest)
create a new local script inside StarterCharacterScripts and put this in: local char = script.Parent
local hum = char:FindFirstChildOfClass("Humanoid")
local animator = hum:FindFirstChildOfClass("Animator")
local current
char:ChildAdded:Connect(function(child)
if child:IsA("Tool") then
local anim = child:FindFirstChild("HoldAnim")
if anim and anim:IsA("Animation") then
if current then current[2]:Stop() current[2]:Destroy() current = nil end
local track = animator:LoadAnimation(anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = true
track:Play()
current = {child, track}
end
end
end)
char.ChildRemoved:Connect(function(child)
if child:IsA("Tool") then
if current and current[1] == child then
current[2]:Stop()
current[2]:Destroy()
current = nil
end
end
end