Advertisement
1_F0

Freeze

May 19th, 2020
8,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. if type(_G.SHUTDOWN_FREEZEPARTS) == "function" then
  2. _G.SHUTDOWN_FREEZEPARTS()
  3. end
  4.  
  5. local Players = game:GetService("Players")
  6. local UserInputService = game:GetService("UserInputService")
  7. local RunService = game:GetService("RunService")
  8. local freeze = false
  9. local anchoredParts = {}
  10. local connect
  11. local connect2
  12. local inputconnect
  13.  
  14. function isCharacter(instance)
  15. for _, p in pairs(Players:GetPlayers()) do
  16. if p.Character and typeof(instance) == "Instance" and instance:IsDescendantOf(p.Character) or instance == p.Character then
  17. return true
  18. end
  19. end
  20. return false
  21. end
  22.  
  23. function _G.SHUTDOWN_FREEZEPARTS()
  24. if freeze then
  25. toggleFreeze()
  26. end
  27. if inputconnect then
  28. inputconnect:Disconnect()
  29. end
  30. end
  31.  
  32. function toggleFreeze()
  33. if not freeze then
  34. freeze = true
  35. for _, v in pairs(workspace:GetDescendants()) do
  36. if v:IsA("BasePart") and not v.Anchored and not isCharacter(v) then
  37. v.Anchored = true
  38. anchoredParts[v] = true
  39. end
  40. end
  41. connect = workspace.DescendantAdded:Connect(function(c)
  42. if c:IsA("BasePart") and not c.Anchored and not isCharacter(c) then
  43. c.Anchored = true
  44. anchoredParts[c] = true
  45. end
  46. if c:IsA("BasePart") then
  47. local changedconnection
  48. changedconnection = c.Changed:Connect(function()
  49. if not freeze then
  50. changedconnection:Disconnect()
  51. return
  52. end
  53. if c:IsA("BasePart") and not c.Anchored and not isCharacter(c) then
  54. c.Anchored = true
  55. anchoredParts[c] = true
  56. end
  57. end)
  58. end
  59. end)
  60. connect2 = RunService.Heartbeat:Connect(function()
  61. for v, _ in pairs(anchoredParts) do
  62. if v.Anchored == false then
  63. v.Anchored = true
  64. end
  65. end
  66. end)
  67. else
  68. freeze = false
  69. if typeof(connect) == "RBXScriptConnection" then
  70. connect:Disconnect()
  71. end
  72. if typeof(connect2) == "RBXScriptConnection" then
  73. connect2:Disconnect()
  74. end
  75. for v, _ in pairs(anchoredParts) do
  76. v.Anchored = false
  77. end
  78. end
  79. end
  80.  
  81. Players.LocalPlayer.SimulationRadius = math.huge
  82.  
  83. inputconnect = UserInputService.InputEnded:Connect(function(input, isTyping)
  84. if input.KeyCode == Enum.KeyCode.F and not isTyping then
  85. toggleFreeze()
  86. end
  87. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement