im trying to make an npc equip/unequip a tool and hold it out but I cant quite figure it out. im wanting to save welding and re-positioning the arm as a last resort.
when i equip a tool it goes on the npc’s right hand but the npc does not hold out the tool like how a player’s character would.
i wrote this but it doesnt work how I want it to:
local idle = "rbxassetid://507766388"
local toolnone = "rbxassetid://507768375"
local anim = Instance.new("Animation")
anim.AnimationId = idle
local LoadedAnim :AnimationTrack
local animNumber = 0
local function AnimLoop(NPC)
animNumber += 1
local CurrentAnim = animNumber
while NPC do
LoadedAnim = NPC.Humanoid:LoadAnimation(anim)
-- i dont think loading the anim in the loop is the best idea
LoadedAnim:Play()
LoadedAnim.Stopped:Wait()
if CurrentAnim ~= animNumber then
break
end
end
end
this is how i run the function:
LoadedAnim:Stop()
anim.AnimationId = toolnone
task.spawn(AnimLoop, NPC)
the given code makes the npc hold out the tool but the npc becomes completely still because the toolnone animation does not have an idle animation. im wanting to somehow combine the both of these, preferably not like how this script does it. is there some sort of roblox function that does this for me that i dont know about?