Advertisement
creativenico

Hat Spin Script

Apr 15th, 2021
3,458
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 KB | None | 1 0
  1. local plr = game.Players.LocalPlayer;
  2. local chr = plr.Character;
  3. local hum = chr.Humanoid;
  4. local mov = {};
  5. local mov2 = {};
  6.  
  7. --[[Network]]
  8. coroutine.resume(coroutine.create(function()
  9. settings().Physics.AllowSleep = false;
  10. game.RunService.RenderStepped:Connect(function()
  11. for i, v in pairs(game.Players:GetPlayers()) do
  12. if v ~= plr then
  13. v.MaximumSimulationRadius = 0.1;
  14. v.SimulationRadius = 0;
  15. else
  16. v.MaximumSimulationRadius = math.pow(math.huge, math.huge);
  17. v.SimulationRadius = math.pow(math.huge, 2);
  18. end
  19. end
  20. end)
  21. end))
  22.  
  23. function ftp(str)
  24. local pt = {};
  25. if str ~= 'me' and str ~= 'random' then
  26. for i, v in pairs(game.Players:GetPlayers()) do
  27. if v.Name:lower():find(str:lower()) then
  28. table.insert(pt, v);
  29. end
  30. end
  31. elseif str == 'me' then
  32. table.insert(pt, plr);
  33. elseif str == 'random' then
  34. table.insert(pt, game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())]);
  35. end
  36. return pt;
  37. end
  38.  
  39. for _, v in pairs(hum:GetAccessories()) do
  40. local b = v.Handle;
  41. b.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0, 0, 0);
  42. b.CanCollide = false;
  43. b:BreakJoints();
  44. for _, k in pairs(v:GetChildren()) do
  45. if not k:IsA'SpecialMesh' and not k:IsA'Part' then
  46. k:Destroy();
  47. end
  48. end
  49. local still = Instance.new('BodyAngularVelocity', b);
  50. still.MaxTorque = Vector3.new(math.huge, math.huge, math.huge);
  51. still.AngularVelocity = Vector3.new(0, 0, 0);
  52. local align = Instance.new('AlignPosition', b);
  53. align.MaxForce = 1000000;
  54. align.MaxVelocity = math.huge;
  55. align.RigidityEnabled = false;
  56. align.ApplyAtCenterOfMass = true;
  57. align.Responsiveness = 200;
  58. local a0 = Instance.new('Attachment', b);
  59. local a1 = Instance.new('Attachment', chr.Head);
  60. align.Attachment0 = a0;
  61. align.Attachment1 = a1;
  62. table.insert(mov, a1);
  63. table.insert(mov2, still);
  64. end
  65.  
  66. local par = {};
  67. for _, v in pairs(mov) do
  68. local parr = Instance.new('Part', workspace);
  69. parr.Anchored = true;
  70. parr.Size = Vector3.new(1, 1, 1);
  71. parr.Transparency = 1;
  72. parr.CanCollide = false;
  73. table.insert(par, parr);
  74. end
  75.  
  76. local rotx = 0;
  77. local rotz = math.pi / 2;
  78. local height = 0;
  79. local heighti = 1;
  80. local offset = 10;
  81. local speed = 0.5;
  82. local mode = 4;
  83. local angular = Vector3.new(0, 0, 0);
  84. local l = 1;
  85. game['Run Service'].RenderStepped:Connect(function()
  86. rotx = rotx + speed / 100;
  87. rotz = rotz + speed / 100;
  88. l = (l >= 360 and 1 or l + speed);
  89.  
  90. for i, v in pairs(par) do
  91. v.CFrame = CFrame.new(chr.HumanoidRootPart.Position) * CFrame.fromEulerAnglesXYZ(0, math.rad(l + (360 / #par) * i + speed), 0) * CFrame.new(offset, 0, 0);
  92. end
  93.  
  94. if heighti == 1 then
  95. height = height + speed / 100;
  96. elseif heighti == 2 then
  97. height = height - speed / 100;
  98. end
  99. if height > 2 then
  100. heighti = 2;
  101. end
  102. if height < -1 then
  103. heighti = 1;
  104. end
  105.  
  106. if mode == 1 then
  107. for _, v in pairs(mov) do
  108. v.Position = Vector3.new(math.sin(rotx) * offset, 0, math.sin(rotz) * offset);
  109. end
  110. elseif mode == 2 then
  111. for _, v in pairs(mov) do
  112. v.Position = Vector3.new(offset, height, offset);
  113. end
  114. elseif mode == 3 then
  115. for _, v in pairs(mov) do
  116. v.Position = Vector3.new(math.sin(rotx) * offset, height, math.sin(rotz) * offset);
  117. end
  118. elseif mode == 4 then
  119. for i, v in pairs(mov) do
  120. v.Position = Vector3.new(chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).X, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Y, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Z);
  121. end
  122. elseif mode == 5 then
  123. for i, v in pairs(mov) do
  124. v.Position = Vector3.new((math.sin(rotx)) * offset, height, (math.cos(rotz) - i) * offset);
  125. end
  126. elseif mode == 6 then
  127. for i, v in pairs(mov) do
  128. v.Position = Vector3.new((math.sin(rotx)) * offset, height, (math.tan(rotz) - i) * offset);
  129. end
  130. elseif mode == 7 then
  131. for i, v in pairs(mov) do
  132. v.Position = Vector3.new(math.cos(rotx * i) * offset, 0, math.cos(rotz * i) * offset);
  133. end
  134. elseif mode == 8 then
  135. for i, v in pairs(mov) do
  136. v.Position = Vector3.new(math.sin(rotx) * i * offset, 0, math.sin(rotz) * i * offset);
  137. end
  138. elseif mode == 9 then
  139. pcall(function()
  140. local so = nil;
  141. for k, b in pairs(chr:GetChildren()) do
  142. if b:IsA'Tool' then
  143. for h, j in pairs(b:GetDescendants()) do
  144. if j:IsA'Sound' then
  145. so = j;
  146. end
  147. end
  148. end
  149. end
  150. if so ~= nil then
  151. offset = so.PlaybackLoudness / 35;
  152. speed = so.PlaybackLoudness / 500;
  153. angular = Vector3.new(0, so.PlaybackLoudness / 75, 0);
  154. end
  155. end)
  156. for i, v in pairs(mov) do
  157. v.Position = Vector3.new(chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).X, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Y, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Z);
  158. end
  159. elseif mode == 10 then
  160. offset = height * 15;
  161. for i, v in pairs(mov) do
  162. v.Position = Vector3.new(chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).X, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Y, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Z);
  163. end
  164. elseif mode == 11 then
  165. for i, v in pairs(mov) do
  166. v.Position = Vector3.new(chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(plr:GetMouse().Hit.p)).X, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(plr:GetMouse().Hit.p)).Y, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(plr:GetMouse().Hit.p)).Z) + Vector3.new(chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).X, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Y, chr.HumanoidRootPart.CFrame:ToObjectSpace(CFrame.new(par[i].Position)).Z);
  167. end
  168. end
  169. for _, v in pairs(mov2) do
  170. v.AngularVelocity = angular;
  171. end
  172. end)
  173. game.Players.LocalPlayer.Chatted:Connect(function(c)
  174. if c:split(' ')[1] == '.orbit' then
  175. for _, v in pairs(mov) do
  176. chr = ftp(c:split(' ')[2])[1].Character;
  177. v.Parent = ftp(c:split(' ')[2])[1].Character.HumanoidRootPart;
  178. end
  179. end
  180. if c:split(' ')[1] == '.speed' then
  181. speed = tonumber(c:split(' ')[2]);
  182. end
  183. if c:split(' ')[1] == '.mode' then
  184. mode = tonumber(c:split(' ')[2]);
  185. end
  186. if c:split(' ')[1] == '.offset' then
  187. offset = tonumber(c:split(' ')[2]);
  188. end
  189. if c:split(' ')[1] == '.angular' then
  190. angular = Vector3.new(tonumber(c:split(' ')[2]), tonumber(c:split(' ')[3]), tonumber(c:split(' ')[4]));
  191. end
  192. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement