Advertisement
moathon

scriptPart5

Apr 29th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. script.Name = "TimeStop"
  2. print(script.Parent.Name)
  3. wait()
  4. local freezing = true
  5. local sound = script.Parent.Handle.TimeResume
  6. local player = script.Parent.Parent
  7. local kids = player:GetDescendants()
  8. local you = game.Players:GetPlayerFromCharacter(player)
  9. --local backpack = you.BackPack:GetChildren()
  10. local frozen = {}
  11. local frozen1 = 1
  12. local younfreezeme = {}
  13. local unfrze = 1
  14. for i=1,#kids do
  15.     if kids[i]:IsA("Script") or kids[i]:IsA("LocalScript") then
  16.         if kids[i].Disabled == false then
  17.         younfreezeme[i]=kids[i]
  18.         unfrze = unfrze + 1
  19.         end
  20.     end
  21. end
  22. wait()
  23. script.Parent = game.Workspace
  24. --for i=1,#kids do
  25.     --print(kids[i].Name)
  26. --end
  27. function unfreezeplr(thing)
  28.     for i=1,#thing do
  29.         if thing[i]:IsA("BasePart") then
  30.             thing[i].Anchored = false
  31.         end
  32.     end
  33.     for ii=1,unfrze do
  34.         if younfreezeme[ii] ~= nil then
  35.         younfreezeme[ii].Disabled = false
  36.         --print(younfreezeme[ii].Name.." was unfrozen")
  37.         ii=ii+1
  38.         end
  39.     end
  40.     end
  41. function freeze(thing)
  42.     if thing:IsA("BasePart") then
  43.         for i=1, #kids do
  44.         if thing.Anchored == false and thing ~= kids[i] then
  45.         thing.Anchored = true
  46.         frozen[frozen1] = thing
  47.         frozen1 = frozen1 + 1
  48.         end
  49.         end
  50.     if thing:IsA("Script") or thing:IsA("LocalScript") then
  51.         for i=1,#kids do
  52.         if thing.Disabled == false and thing ~= kids[i] then
  53.             thing.Disabled = true
  54.             frozen[frozen1] = thing
  55.             frozen1 = frozen1+1
  56.         end
  57.         end
  58.         end
  59.     end
  60. end
  61. function doublecheck(thing)
  62.     if thing:IsA("Tool") then
  63.         --print("A tool was equipped")
  64.         local getkids = thing:GetDescendants()
  65.         if thing.Parent == player then
  66.             --print("This tools parent is firemomo45")
  67.              for i, v in pairs(frozen) do
  68.         if (frozen[i] == getkids[i]) then
  69.             --print("One of this tools kids is anchored")
  70.             if getkids[i]:IsA("BasePart") then
  71.                 getkids[i].Anchored = false
  72.                 --print(getkids[i].Name.." was unfrozen")
  73.             end
  74.             if getkids[i]:IsA("Script") or getkids[i]:IsA("LocalScript") then
  75.                 getkids[i].Disabled = false
  76.                 --print(getkids[i].Name.." was undisabled")
  77.             end
  78.        end
  79.     end
  80.         end
  81.     end
  82.      for i, v in pairs(kids) do
  83.             if kids[i]:IsA("BasePart") then
  84.                 kids[i].Anchored = false
  85.                 --print(kids[i].Name.." was unfrozen")
  86.             end
  87.             if kids[i].Name == "Handle" then
  88.                 kids[i].Anchored = false
  89.                 --print(kids[i].Name.." was unfrozen")
  90.             end
  91.             if (kids[i] == frozen[i]) then
  92.             if kids[i]:IsA("Script") or kids[i]:IsA("LocalScript") then
  93.                 kids[i].Disabled = false
  94.                 --print(kids[i].Name.." was undisabled")
  95.             end
  96.         end
  97.     end
  98. end
  99. game.Workspace.DescendantAdded:Connect(function(thing)
  100.     if freezing == true then
  101.         freeze(thing)
  102.         doublecheck(thing)
  103.         unfreezeplr(kids)
  104.     end
  105. end)
  106. player.DescendantAdded:Connect(function(thing)
  107.         --print(thing.Name)
  108.         wait()
  109.         if thing:IsA("Part") then
  110.             thing.Anchored = false
  111.         end
  112. end)
  113. sound.Ended:Connect(function()
  114.     wait(1)
  115.     freezing = false
  116.     for i=1,#frozen do
  117.         if frozen[i]:IsA("Script") or frozen[i]:IsA("LocalScript") then
  118.             frozen[i].Disabled = false
  119.         end
  120.         if frozen[i]:IsA("BasePart") then
  121.             frozen[i].Anchored = false
  122.         end
  123.     end
  124.     wait()
  125.     script:Destroy()
  126. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement