Advertisement
jordan83221

Record

Jul 25th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.46 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 parts={}
  50. local function logp(part)
  51.     local clone=part:Clone()
  52.     clone.Name=part.Name
  53.     clone.Anchored=true
  54.     local x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22=part.CFrame:components()
  55.     clone.CFrame=CFrame.new(x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22)
  56.     for _,v in next,game.Lighting:GetChildren() do
  57.         local a,b=string.match(v.Name,"(.*):%s(.*)")
  58.         if a==clone.Name then
  59.             clone.Parent=v
  60.         end
  61.     end
  62.     local attached=Instance.new("ObjectValue",clone)
  63.     attached.Name="ObjectValue"
  64.     attached.Value=part
  65. end
  66. local function repl(part)
  67.     if part and part.ObjectValue then
  68.         part.ObjectValue.Value.CFrame=part.CFrame
  69.     end
  70. end
  71. local function getAnchored(part)
  72.     for _,v in next,game.Lighting:GetChildren() do
  73.         local a,b=string.match(v.Name,"(.*):%s(.*)")
  74.         if a==part.Name then
  75.             if b=="true" then
  76.                 return true
  77.             elseif b=="false" then
  78.                 return false
  79.             end
  80.         end
  81.     end
  82. end
  83. local logs={}
  84. local cmds={
  85.     ["record"]=function(a)
  86.         if wiped==true then
  87.             if play==true then
  88.                 for i=1,a do game:service'RunService'.RenderStepped:wait()
  89.                     coroutine.resume(coroutine.create(function()
  90.                         for _,v in next,parts do
  91.                             if v:IsA("Part") and v.Name~="Baseplate" and v.Name~="Base" and v.Name~="Part" and v then
  92.                                 logp(v)
  93.                             end
  94.                         end
  95.                     end))
  96.                     notify("Logging: "..i)
  97.                 end
  98.             else
  99.                 notify("You must be able to move to record!")
  100.             end
  101.         else
  102.             notify("You must wipe the old recordings to record new ones!")
  103.         end
  104.     end,
  105.     ["rewind"]=function(a)
  106.         if play==false then
  107.             for _,v in next,game.Lighting:GetChildren() do
  108.                 coroutine.resume(coroutine.create(function()
  109.                     for i=a,1,-1 do game:service'RunService'.RenderStepped:wait()
  110.                         repl(v:GetChildren()[i])
  111.                     end
  112.                 end))
  113.             end
  114.             notify("Finished rewinding!")
  115.         else
  116.             notify("Must be paused to rewind!")
  117.         end
  118.         wiped=false
  119.     end,
  120.     ["play"]=function()
  121.         if play==false then
  122.             play=true
  123.             for _,v in next,parts do
  124.                 if getAnchored(v)==false then
  125.                     v.Anchored=false
  126.                 end
  127.             end
  128.         end
  129.     end,
  130.     ["pause"]=function()
  131.         if play==true then
  132.             play=false
  133.             for _,v in next,parts do
  134.                 if v.className=="Part" and v.Anchored==false then
  135.                     v.Anchored=true
  136.                 end
  137.             end
  138.         end
  139.     end,
  140.     ["wipe"]=function()
  141.         for _,v in next,game.Lighting:GetChildren() do
  142.             if v:IsA("Model") then
  143.                 for i,g in next,v:GetChildren() do
  144.                     if g:IsA("Part") then
  145.                         g:Destroy()
  146.                     end
  147.                 end
  148.             end
  149.         end
  150.         wiped=true
  151.         notify("Wiped!")
  152.     end,
  153.     ["g"]=function(a)
  154.         if a=="help" then
  155.             notify("CMDS:")
  156.             notify("record/X, Example: record/100, records 100 frames.")
  157.             notify("rewind/X, Example: rewind/100, rewinds 100 frames.")
  158.             notify("play/, Example: play/, resumes movement after paused or rewinded.")
  159.             notify("pause/, Example: pause/, pauses movement.")
  160.             notify("wipe/, Example: wipe, wipes all recordings.")
  161.             notify("g/, Example: g/help, gets help.")
  162.         end
  163.     end
  164. }
  165. local function onChatted(m)
  166.     local cmd,parm=string.match(m,"(.*)/(.*)")
  167.     if cmd and parm then
  168.         cmd=cmd:lower()
  169.         parm=parm:lower()
  170.         cmds[cmd](parm)
  171.     end
  172. end
  173. game.Players.LocalPlayer.Chatted:connect(function(msg) onChatted(msg) end)
  174. notify("Welcome to time manipulation.")
  175. notify("This is a lot like a FastFoward and a Rewind system.")
  176. notify("Need help? Type g/help for help")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement