Advertisement
StefanBashkir

Correctly Create Humanoid

Dec 15th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. -- anchor the NPC before using this
  2. -- delete the Humanoid that is in the model too
  3. local model = script['Parent'];
  4. local torso = model.Torso
  5. local head = model['Head']
  6.  
  7. for i,v in pairs(model:GetChildren()) do
  8.     if v ~= torso and v:IsA([==[BasePart]==]) then
  9.         local w = Instance.new([==[Weld]==], game.JointsService);
  10.         w.C1 = v.CFrame:toObjectSpace(torso.CFrame);
  11.         w.Part0 = torso
  12.         w.Part1 = v
  13.     end
  14. end
  15.  
  16. local human = Instance.new("Humanoid")
  17. human.MaxHealth = 100
  18. human.Health = 100
  19. human.WalkSpeed = 16
  20.  
  21. for i,v in pairs(model:GetChildren()) do
  22.     if v:IsA("BasePart") then
  23.         v.Anchored = not true;
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement