Advertisement
SnorlaxScript

Untitled

Jan 27th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. p = game.Players.LocalPlayer
  2. char = p.Character
  3. hum = char.Humanoid
  4. root=char.HumanoidRootPart
  5. torso = char.Torso
  6. local player = game.Players.LocalPlayer
  7. lig = Instance.new("PointLight",player.Character.Torso)
  8. lig.Color=Color3.new(255,0,0)
  9. m=player:GetMouse()
  10. bb = Instance.new("BillboardGui",player.Character.Head)
  11. bb.Enabled = true
  12. function newRay(start,face,range,wat)
  13. local rey=Ray.new(start.p,(face.p-start.p).Unit*range)
  14. hit,pos=Workspace:FindPartOnRayWithIgnoreList(rey,wat)
  15. return rey,hit,pos
  16. end
  17. aa1={}
  18. torso=game.Players.LocalPlayer.Character.Torso
  19.  
  20. local WorldUp = Vector3.new(0,1,0)
  21. function look2(Vec1,Vec2)
  22. local Orig = Vec1
  23. Vec1 = Vec1+Vector3.new(0,1,0)
  24. Vec2 = Vec2+Vector3.new(0,1,0)
  25. local Forward = (Vec2-Vec1).unit
  26. local Up = (WorldUp-WorldUp:Dot(Forward)*Forward).unit
  27. local Right = Up:Cross(Forward).unit
  28. Forward = -Forward
  29. Right = -Right
  30. return CFrame.new(Orig.X,Orig.Y,Orig.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z)
  31. end
  32.  
  33. function look(CFr,Vec2)
  34. local A = Vector3.new(0,0,0)
  35. local B = CFr:inverse()*Vec2
  36. local CF = look2(A,Vector3.new(A.X,B.Y,B.Z))
  37. if B.Z > 0 then
  38. CF = CFr*(CF*CFrame.Angles(0,0,math.pi))
  39. elseif B.Z == 0 then
  40. if B.Y > 0 then
  41. CF = CFr*CFrame.Angles(math.pi/2,0,0)
  42. elseif B.Y < 0 then
  43. CF = CFr*CFrame.Angles(-math.pi/2,0,0)
  44. else
  45. CF = CFr
  46. end
  47. end
  48. local _,_,_,_,X,_,_,Y,_,_,Z,_ = CF:components()
  49. local Up = Vector3.new(X,Y,Z)
  50. local Forward = (Vec2-CFr.p).unit
  51. local Right = Up:Cross(Forward)
  52. Forward = -Forward
  53. Right = -Right
  54. return CFrame.new(CFr.X,CFr.Y,CFr.Z,Right.X,Up.X,Forward.X,Right.Y,Up.Y,Forward.Y,Right.Z,Up.Z,Forward.Z)
  55. end
  56.  
  57. function simulate(j,d,m,r,t)
  58. local joint = j
  59. for i,v in ipairs(t) do
  60. if v[1]:FindFirstChild("Weld") then
  61. local stiff = m.CFrame.lookVector*0.03
  62. if i > 1 then joint = t[i-1][1].CFrame*CFrame.new(0,0,d*.5) end
  63. local dir = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).unit
  64. local dis = (v[2].p-(joint.p+Vector3.new(0,0.2,0)+stiff)).magnitude
  65. local pos = joint.p+(dir*(d*0.5))
  66. --if v[1].CFrame.y<=workspace.Base.CFrame.y then pos = joint.p+(dir*(d*.5)) end
  67. local inv = v[1].Weld.Part0.CFrame
  68. local rel1 = inv:inverse()*pos
  69. local rel2 = inv:inverse()*(pos-(dir*dis))
  70. local cf = look(CFrame.new(rel1),rel2)--CFrame.new(pos,pos-(dir*dis))*CFrame.fromEulerAnglesXYZ(r.x,r.y,r.z)
  71. v[1].Weld.C0 = cf
  72. v[2] = inv*cf
  73. --v[1].CFrame = cf
  74. end
  75. end
  76. end
  77. for i=1,8 do
  78. local p = Instance.new("Part",char)
  79. p.Anchored = false
  80. p.BrickColor = BrickColor.new("Really black","Black")
  81. p.CanCollide = false
  82. p.FormFactor="Custom"
  83. p.Material = "Granite"
  84. p.TopSurface = "SmoothNoOutlines"
  85. p.BottomSurface = "SmoothNoOutlines"
  86. p.RightSurface = "SmoothNoOutlines"
  87. p.LeftSurface = "SmoothNoOutlines"
  88. p.FrontSurface = "SmoothNoOutlines"
  89. p.BackSurface = "SmoothNoOutlines"
  90.  
  91. p.Size=Vector3.new(2,.2,0.2)
  92. p:BreakJoints() -- sometimes the parts are stuck to something so you have to breakjoints them
  93. mesh = Instance.new("BlockMesh",p)
  94. mesh.Scale = Vector3.new(1,1,4)
  95. local w = Instance.new("Motor6D",p)
  96. w.Part0 = aa1[i-1] and aa1[i-1][1] or torso
  97. w.Part1 = p
  98. w.Name = "Weld"
  99. --table.insert(aa1,p)
  100. aa1[i] = {p,p.CFrame}
  101.  
  102. end
  103. game:service"RunService".Stepped:connect(function()
  104. simulate(torso.CFrame*CFrame.new(0,0.9,.5),.6,torso,Vector3.new(),aa1)
  105. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement