Advertisement
jordan83221

Record2

Jul 25th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.45 KB | None | 0 0
  1. wait()
  2. script.Parent=nil
  3. local next=next
  4. local pcall=pcall
  5. local rad=math.rad
  6. local insert=table.insert
  7. local play=true
  8. local remove=table.remove
  9. local wiped=true
  10. local plrs=game.Players:GetPlayers()
  11. local plr=game.Players.LocalPlayer.Character
  12. local parts={}
  13. local scripts={}
  14. local WS=workspace:GetChildren()
  15. local function getAllParts(tab)
  16.     for _,v in next,tab:GetChildren() do
  17.         if v:IsA("Part") and v.Name~="Baseplate" and v.Name~="Base" and v.Name~="Part" and v then
  18.             local model=Instance.new("Model",game.Lighting)
  19.             if v.Anchored==true then
  20.                 model.Name=v.Name..": true"
  21.             elseif v.Anchored==false then
  22.                 model.Name=v.Name..": false"
  23.             end
  24.             table.insert(parts,v)
  25.         else
  26.             getAllParts(v)
  27.         end
  28.     end
  29. end
  30. getAllParts(workspace)
  31. local function getAllScripts(tab)
  32.     for _,v in next,tab:GetChildren() do
  33.         if v:IsA("Script") or v:IsA("LocalScript") then
  34.             table.insert(scripts,v)
  35.         else
  36.             getAllScripts(v)
  37.         end
  38.     end
  39. end
  40. getAllScripts(workspace)
  41. local function notify(m)
  42.     game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
  43.     Text = m;
  44.     Color = Color3.new(0,1,1);
  45.     Font = Enum.Font.SourceSans;
  46.     FontSize = Enum.FontSize.Size14;
  47.     })
  48. end
  49. local function logp(part)
  50.     local clone=part:Clone()
  51.     clone.Name=part.Name
  52.     clone.Anchored=true
  53.     local x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22=part.CFrame:components()
  54.     clone.CFrame=CFrame.new(x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22)
  55.     for _,v in next,game.Lighting:GetChildren() do
  56.         local a,b=string.match(v.Name,"(.*):%s(.*)")
  57.         if a==clone.Name then
  58.             clone.Parent=v
  59.         end
  60.     end
  61.     local attached=Instance.new("ObjectValue",clone)
  62.     attached.Name="ObjectValue"
  63.     attached.Value=part
  64. end
  65. local function repl(part)
  66.     if part and part.ObjectValue then
  67.         part.ObjectValue.Value.CFrame=part.CFrame
  68.     end
  69. end
  70. local function getAnchored(part)
  71.     for _,v in next,game.Lighting:GetChildren() do
  72.         local a,b=string.match(v.Name,"(.*):%s(.*)")
  73.         if a==part.Name then
  74.             if b=="true" then
  75.                 return true
  76.             elseif b=="false" then
  77.                 return false
  78.             end
  79.         end
  80.     end
  81. end
  82. local logs={}
  83. local cmds={
  84.     ["record"]=function(a)
  85.         if wiped==true then
  86.             if play==true then
  87.                 for i=1,a do game:service'RunService'.RenderStepped:wait()
  88.                     coroutine.resume(coroutine.create(function()
  89.                         for _,v in next,parts do
  90.                             if v:IsA("Part") and v.Name~="Baseplate" and v.Name~="Base" and v.Name~="Part" and v then
  91.                                 logp(v)
  92.                             end
  93.                         end
  94.                     end))
  95.                     notify("Logging: "..i)
  96.                 end
  97.             else
  98.                 notify("You must be able to move to record!")
  99.             end
  100.         else
  101.             notify("You must wipe the old recordings to record new ones!")
  102.         end
  103.     end,
  104.     ["rewind"]=function(a)
  105.         if play==false then
  106.             for _,v in next,game.Lighting:GetChildren() do
  107.                 coroutine.resume(coroutine.create(function()
  108.                     for i=a,1,-1 do game:service'RunService'.RenderStepped:wait()
  109.                         repl(v:GetChildren()[i])
  110.                     end
  111.                 end))
  112.             end
  113.             notify("Finished rewinding!")
  114.         else
  115.             notify("Must be paused to rewind!")
  116.         end
  117.         wiped=false
  118.     end,
  119.     ["play"]=function()
  120.         if play==false then
  121.             play=true
  122.             for _,v in next,parts do
  123.                 if getAnchored(v)==false then
  124.                     v.Anchored=false
  125.                 end
  126.             end
  127.         end
  128.     end,
  129.     ["pause"]=function()
  130.         if play==true then
  131.             play=false
  132.             for _,v in next,parts do
  133.                 if v.className=="Part" and v.Anchored==false then
  134.                     v.Anchored=true
  135.                 end
  136.             end
  137.         end
  138.     end,
  139.     ["wipe"]=function()
  140.         for _,v in next,game.Lighting:GetChildren() do
  141.             if v:IsA("Model") then
  142.                 for i,g in next,v:GetChildren() do
  143.                     if g:IsA("Part") then
  144.                         g:Destroy()
  145.                     end
  146.                 end
  147.             end
  148.         end
  149.         wiped=true
  150.         notify("Wiped!")
  151.     end,
  152.     ["g"]=function(a)
  153.         if a=="help" then
  154.             notify("CMDS:")
  155.             notify("record/X, Example: record/100, records 100 frames.")
  156.             notify("rewind/X, Example: rewind/100, rewinds 100 frames.")
  157.             notify("play/, Example: play/, resumes movement after paused or rewinded.")
  158.             notify("pause/, Example: pause/, pauses movement.")
  159.             notify("wipe/, Example: wipe, wipes all recordings.")
  160.             notify("g/, Example: g/help, gets help.")
  161.         end
  162.     end
  163. }
  164. local function onChatted(m)
  165.     local cmd,parm=string.match(m,"(.*)/(.*)")
  166.     if cmd and parm then
  167.         cmd=cmd:lower()
  168.         parm=parm:lower()
  169.         cmds[cmd](parm)
  170.     end
  171. end
  172. game.Players.LocalPlayer.Chatted:connect(function(msg) onChatted(msg) end)
  173. notify("Welcome to time manipulation.")
  174. notify("This is a lot like a FastFoward and a Rewind system.")
  175. notify("Need help? Type g/help for help")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement