Advertisement
szze

FE Npc controller

Jan 25th, 2023 (edited)
9,853
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 1 0
  1. -- Variables
  2. local mouse = game:GetService'Players'.LocalPlayer:GetMouse()
  3. local uis = game:GetService("UserInputService")
  4.  
  5. -- Connect
  6. mouse.Button1Down:Connect(function()
  7. -- Check for Target & Left Shift
  8. if mouse.Target and uis:IsKeyDown(Enum.KeyCode.LeftControl) then
  9. local npc = mouse.target.Parent
  10. local npcRootPart
  11. local npcRootPart = npc:FindFirstChildWhichIsA'Humanoid'.RootPart
  12. if not npcRootPart then npcRootPart = npc:FindFirstChild'HumanoidRootPart' end
  13. local PlayerCharacter = game:GetService("Players").LocalPlayer.Character
  14. local PlayerRootPart = PlayerCharacter.HumanoidRootPart
  15. local A0 = Instance.new("Attachment")
  16. local AP = Instance.new("AlignPosition")
  17. local AO = Instance.new("AlignOrientation")
  18. local A1 = Instance.new("Attachment")
  19. for _, v in pairs(npc:GetDescendants()) do
  20. if v:IsA("BasePart") then
  21. game:GetService("RunService").Stepped:Connect(function()
  22. v.CanCollide = false
  23. end)
  24. end
  25. end
  26. PlayerRootPart:BreakJoints()
  27. for _, v in pairs(PlayerCharacter:GetDescendants()) do
  28. if v:IsA("BasePart") then
  29. if v.Name == "HumanoidRootPart" or v.Name == "UpperTorso" or v.Name == "Head" then
  30. else
  31. v:Destroy()
  32. end
  33. end
  34. end
  35. PlayerRootPart.Position = PlayerRootPart.Position + Vector3.new(5, 0, 0)
  36. PlayerCharacter.Head.Anchored = true
  37. PlayerCharacter.UpperTorso.Anchored = true
  38. A0.Parent = npcRootPart
  39. AP.Parent = npcRootPart
  40. AO.Parent = npcRootPart
  41. AP.Responsiveness = 200
  42. AP.MaxForce = math.huge
  43. AO.MaxTorque = math.huge
  44. AO.Responsiveness = 200
  45. AP.Attachment0 = A0
  46. AP.Attachment1 = A1
  47. AO.Attachment1 = A1
  48. AO.Attachment0 = A0
  49. A1.Parent = PlayerRootPart
  50. end
  51. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement