carlosname

Untitled

May 7th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- [[ Time Stop ]] ---
  2.  
  3. --https://github.com/Mokiros/roblox-FE-compatibility
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,game,owner = owner,game
  6. local RealPlayer = Player
  7. do
  8.     print("FE Compatibility code V2 by Mokiros")
  9.     local RealPlayer = RealPlayer
  10.     script.Parent = RealPlayer.Character
  11.  
  12.     --Fake event to make stuff like Mouse.KeyDown work
  13.     local Disconnect_Function = function(this)
  14.         this[1].Functions[this[2]] = nil
  15.     end
  16.     local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  17.     local FakeEvent_Metatable = {__index={
  18.         Connect = function(this,f)
  19.             local i = tostring(math.random(0,10000))
  20.             while this.Functions[i] do
  21.                 i = tostring(math.random(0,10000))
  22.             end
  23.             this.Functions[i] = f
  24.             return setmetatable({this,i},Disconnect_Metatable)
  25.         end
  26.     }}
  27.     FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  28.     local function fakeEvent()
  29.         return setmetatable({Functions={}},FakeEvent_Metatable)
  30.     end
  31.  
  32.     --Creating fake input objects with fake variables
  33.     local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  34.     FakeMouse.keyUp = FakeMouse.KeyUp
  35.     FakeMouse.keyDown = FakeMouse.KeyDown
  36.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  37.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  38.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  39.     end}
  40.     --Merged 2 functions into one by checking amount of arguments
  41.     CAS.UnbindAction = CAS.BindAction
  42.  
  43.     --This function will trigger the events that have been :Connect()'ed
  44.     local function TriggerEvent(self,ev,...)
  45.         for _,f in pairs(self[ev].Functions) do
  46.             f(...)
  47.         end
  48.     end
  49.     FakeMouse.TriggerEvent = TriggerEvent
  50.     UIS.TriggerEvent = TriggerEvent
  51.  
  52.     --Client communication
  53.     local Event = Instance.new("RemoteEvent")
  54.     Event.Name = "UserInput_Event"
  55.     Event.OnServerEvent:Connect(function(plr,io)
  56.         if plr~=RealPlayer then return end
  57.         FakeMouse.Target = io.Target
  58.         FakeMouse.Hit = io.Hit
  59.         if not io.isMouse then
  60.             local b = io.UserInputState == Enum.UserInputState.Begin
  61.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  62.                 return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  63.             end
  64.             if io.UserInputType == Enum.UserInputType.MouseButton2 then
  65.                 return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  66.             end
  67.             for _,t in pairs(CAS.Actions) do
  68.                 for _,k in pairs(t.Keys) do
  69.                     if k==io.KeyCode then
  70.                         t.Function(t.Name,io.UserInputState,io)
  71.                     end
  72.                 end
  73.             end
  74.             FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  75.             UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  76.         end
  77.     end)
  78.     Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  79.     local Mouse = owner:GetMouse()
  80.     local UIS = game:GetService("UserInputService")
  81.     local input = function(io,RobloxHandled)
  82.         if RobloxHandled then return end
  83.         --Since InputObject is a client-side instance, we create and pass table instead
  84.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  85.     end
  86.     UIS.InputBegan:Connect(input)
  87.     UIS.InputEnded:Connect(input)
  88.     local h,t
  89.     --Give the server mouse data every second frame, but only if the values changed
  90.     --If player is not moving their mouse, client won't fire events
  91.     local HB = game:GetService("RunService").Heartbeat
  92.     while true do
  93.         if h~=Mouse.Hit or t~=Mouse.Target then
  94.             h,t=Mouse.Hit,Mouse.Target
  95.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  96.         end
  97.         --Wait 2 frames
  98.         for i=1,2 do
  99.             HB:Wait()
  100.         end
  101.     end]==],script)
  102.  
  103.     ----Sandboxed game object that allows the usage of client-side methods and services
  104.     --Real game object
  105.     local RealGame = game
  106.  
  107.     --Metatable for fake service
  108.     local FakeService_Metatable = {
  109.         __index = function(self,k)
  110.             local s = rawget(self,"_RealService")
  111.             if s then
  112.                 return typeof(s[k])=="function"
  113.                 and function(_,...)return s[k](s,...)end or s[k]
  114.             end
  115.         end,
  116.         __newindex = function(self,k,v)
  117.             local s = rawget(self,"_RealService")
  118.             if s then s[k]=v end
  119.         end
  120.     }
  121.     local function FakeService(t,RealService)
  122.         t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  123.         return setmetatable(t,FakeService_Metatable)
  124.     end
  125.  
  126.     --Fake game object
  127.     local FakeGame = {
  128.         GetService = function(self,s)
  129.             return rawget(self,s) or RealGame:GetService(s)
  130.         end,
  131.         Players = FakeService({
  132.             LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  133.         },"Players"),
  134.         UserInputService = FakeService(UIS,"UserInputService"),
  135.         ContextActionService = FakeService(CAS,"ContextActionService"),
  136.         RunService = FakeService({
  137.             _btrs = {},
  138.             RenderStepped = RealGame:GetService("RunService").Heartbeat,
  139.             BindToRenderStep = function(self,name,_,fun)
  140.                 self._btrs[name] = self.Heartbeat:Connect(fun)
  141.             end,
  142.             UnbindFromRenderStep = function(self,name)
  143.                 self._btrs[name]:Disconnect()
  144.             end,
  145.         },"RunService")
  146.     }
  147.     rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  148.     FakeGame.service = FakeGame.GetService
  149.     FakeService(FakeGame,game)
  150.     --Changing owner to fake player object to support owner:GetMouse()
  151.     game,owner = FakeGame,FakeGame.Players.LocalPlayer
  152. end
  153.  
  154. -- by fo43123
  155.  
  156. local me = game.Players.LocalPlayer
  157. local mouse = me:GetMouse()
  158. local char = me.Character
  159. local hum = char:FindFirstChild('Humanoid')
  160. local hd = char:FindFirstChild('Head')
  161. local ts = char:FindFirstChild('Torso') or char:FindFirstChild('UpperTorso')
  162. local ra = char:FindFirstChild('Right Arm') or char:FindFirstChild('RightUpperArm')
  163. local la = char:FindFirstChild('Left Arm') or char:FindFirstChild('LeftUpperArm')
  164. local rl = char:FindFirstChild('Right Leg') or char:FindFirstChild('RightUpperLeg')
  165. local ll = char:FindFirstChild('Left Leg') or char:FindFirstChild('LeftUpperLeg')
  166. local root = char:FindFirstChild('HumanoidRootPart')
  167. local rj = root:FindFirstChild('RootJoint')
  168. local rs = ts:FindFirstChild('Right Shoulder')
  169. local ls = ts:FindFirstChild('Left Shoulder')
  170. local rh = ts:FindFirstChild('Right Hip')
  171. local lh = ts:FindFirstChild('Left Hip')
  172. local nk = ts:FindFirstChild('Neck')
  173. local anim = char:FindFirstChild('Animate')
  174. local base = workspace:FindFirstChild('Baseplate') or workspace:FindFirstChild('Base')
  175. local cantimestop = true
  176. local cooldown = false
  177. local cc = workspace.CurrentCamera
  178. local cos = math.cos
  179. local sin = math.sin
  180. local rad = math.rad
  181. local rand = math.random
  182. local cfn = CFrame.new
  183. local cfa = CFrame.Angles
  184. local v3 = Vector3.new
  185. local str = string
  186. local unfreeze = {}
  187. local health = {}
  188. local connect = {}
  189. local sine = 0
  190. local effects = nil
  191. hum.WalkSpeed = 23
  192. if char:FindFirstChild('Effects') then
  193.     effects = char:FindFirstChild('Effects')
  194. else
  195.     effects = Instance.new('Folder', char)
  196.     effects.Name = 'Effects'
  197. end
  198.  
  199. ArtificialHB = Instance.new('BindableEvent', script)
  200. ArtificialHB.Name = 'Heartbeat'
  201. script:WaitForChild('Heartbeat')
  202.  
  203. frame = 1 / 60
  204. tf = 0
  205. allowframeloss = false
  206. tossremainder = false
  207. lastframe = tick()
  208. script.Heartbeat:Fire()
  209.  
  210. game:GetService('RunService').Heartbeat:connect(function(s, p)
  211.     tf = tf + s
  212.     if tf >= frame then
  213.         if allowframeloss then
  214.             script.Heartbeat:Fire()
  215.             lastframe = tick()
  216.         else
  217.             for i = 1, math.floor(tf / frame) do
  218.                 script.Heartbeat:Fire()
  219.             end
  220.             lastframe = tick()
  221.         end
  222.         if tossremainder then
  223.             tf = 0
  224.         else
  225.             tf = tf - frame * math.floor(tf / frame)
  226.         end
  227.     end
  228. end)
  229.  
  230. function swait(t)
  231.     if t == 0 or t == nil then
  232.         script.Heartbeat.Event:Wait()
  233.     else
  234.         for i = 0, t do
  235.             script.Heartbeat.Event:Wait()
  236.         end
  237.     end
  238. end
  239.  
  240. function sound(id, parent, vol, pitch, timepos)
  241.     local s = Instance.new('Sound')
  242.     s.Parent = parent
  243.     s.SoundId = id
  244.     s.Volume = vol
  245.     s.PlaybackSpeed = pitch
  246.     s.TimePosition = timepos
  247.     s:Play()
  248.     game.Debris:AddItem(s, s.PlaybackSpeed + 5)
  249. end
  250.  
  251. function camshake(duration, intensity)
  252.     coroutine.wrap(function()
  253.         for i = 1, duration do
  254.             hum.CameraOffset = hum.CameraOffset:lerp(v3(rand(-1, 1), rand(-1, 1), rand(-1, 1)), 0.1 * intensity)
  255.             swait()
  256.         end
  257.         hum.CameraOffset = v3(0, 0, 0)
  258.     end)()
  259. end
  260.  
  261. function findascendant(obj, class)
  262.     local par = obj
  263.     local ret = nil
  264.     pcall(function()
  265.         repeat
  266.             par = par.Parent
  267.             if par:IsA(class) then
  268.                 ret = par
  269.                 break
  270.             end
  271.         until par == nil
  272.     end)
  273.     return ret
  274. end
  275.  
  276. local TimeStopSounds = {
  277.    
  278.     TimeStop = 'rbxassetid://2152227673';
  279.     TimeResume = 'rbxassetid://864569342';
  280.    
  281. }
  282.  
  283. function timestop()
  284.     cantimestop = false
  285.     coroutine.wrap(function()
  286.     local effect1 = Instance.new('Part', effects)
  287.     effect1.Shape = 'Ball'
  288.     effect1.Material = 'ForceField'
  289.     effect1.Anchored = true
  290.     effect1.CanCollide = false
  291.     effect1.Size = v3(0, 0, 0)
  292.     effect1.Transparency = 0
  293.     sound(TimeStopSounds.TimeStop, ts, 5, 1, 0)
  294.     for i,v in pairs(workspace:GetDescendants()) do
  295.         if v:IsA('BasePart') then
  296.             if not v.Anchored and not findascendant(v, 'Tool') and not findascendant(v, 'HopperBin') then
  297.                 if not v:IsDescendantOf(char) then
  298.                     v.Anchored = true
  299.                     table.insert(unfreeze, v)
  300.                 end
  301.             end
  302.         end
  303.         if v:IsA('Sound') then
  304.             if not v:IsDescendantOf(char) then
  305.                 if v.IsPlaying then
  306.                     v:Pause()
  307.                     table.insert(unfreeze, v)
  308.                 end
  309.             end
  310.         end
  311.         if v:IsA('Humanoid') then
  312.             local last = v.Health
  313.             local always = last
  314.             local e = v.HealthChanged:connect(function(hp)
  315.                 if last - hp > 0 then
  316.                     table.insert(health, {humanoid = v, change = last - hp})
  317.                 end
  318.                 last = hp
  319.                 v.Health = always
  320.             end)
  321.             table.insert(connect, e)
  322.         end
  323.         if v:IsA('BodyVelocity') then
  324.             local lastforce = v.MaxForce
  325.             v.MaxForce = v3(0, 0, 0)
  326.             table.insert(unfreeze, {force = v, change = lastforce})
  327.         end
  328.         if v:IsA('BodyPosition') then
  329.             local lastposition = v.MaxForce
  330.             local lastD = v.D
  331.             local lastP = v.P
  332.             v.MaxForce = v3(0, 0, 0)
  333.             v.D = 0
  334.             v.P = 0
  335.             table.insert(unfreeze, {position = v, change = lastposition, dchange = lastD, pchange = lastP})
  336.         end
  337.         if v:IsA('BodyForce') then
  338.             local lastforce2 = v.Force
  339.             v.Force = v3(0, 0, 0)
  340.             table.insert(unfreeze, {force2 = v, fchange = lastforce2})
  341.         end
  342.     end
  343.     ee = workspace.DescendantAdded:Connect(function(v)
  344.         if v:IsA('BasePart') then
  345.             if not v.Anchored and not findascendant(v, 'Tool') and not findascendant(v, 'HopperBin') then
  346.                 if not v:IsDescendantOf(char) then
  347.                     v.Anchored = true
  348.                     table.insert(unfreeze, v)
  349.                 end
  350.             end
  351.         end
  352.         if v:IsA('Sound') then
  353.             if not v:IsDescendantOf(char) then
  354.                 if v.IsPlaying then
  355.                     v:Pause()
  356.                     table.insert(unfreeze, v)
  357.                 end
  358.             end
  359.         end
  360.         if v:IsA('Humanoid') then
  361.             local last = v.Health
  362.             local always = last
  363.             local e = v.HealthChanged:connect(function(hp)
  364.                 if last - hp > 0 then
  365.                     table.insert(health, {humanoid = v, change = last - hp})
  366.                 end
  367.                 last = hp
  368.                 v.Health = always
  369.             end)
  370.             table.insert(connect, e)
  371.         end
  372.     end)
  373.  
  374.     coroutine.wrap(function()
  375.         for i = 1, 10 do
  376.             camshake(70, 2)
  377.  
  378.             swait(5)
  379.         end
  380.     end)()
  381.     coroutine.wrap(function()
  382.     for i = 1, 1000 do
  383.         effect1.CFrame = ts.CFrame
  384.         effect1.Size = effect1.Size:lerp(v3(50, 50, 50), 0.015)
  385.         effect1.Transparency = effect1.Transparency + 0.010
  386.         if effect1.Transparency >= 1 then
  387.             effect1:Destroy()
  388.         end
  389.         swait()
  390.     end
  391.     end)()
  392.     wait(0.5)
  393.     local effect2 = Instance.new('Part', effects)
  394.     local effect3 = Instance.new('Part', effects)
  395.     effect3.Shape = 'Ball'
  396.     effect3.Material = 'ForceField'
  397.     effect3.Anchored = true
  398.     effect3.CanCollide = false
  399.     effect3.Size = v3(0, 0, 0)
  400.     effect3.Transparency = 0
  401.     effect2.Shape = 'Ball'
  402.     effect2.Material = 'ForceField'
  403.     effect2.Anchored = true
  404.     effect2.CanCollide = false
  405.     effect2.Size = v3(40, 40, 40)
  406.     effect2.Transparency = 1
  407.     coroutine.wrap(function()
  408.         for i = 1, 15 do
  409.             effect2.Transparency = effect2.Transparency - 0.11
  410.             swait()
  411.         end
  412.     end)()
  413.     coroutine.wrap(function()
  414.         for i = 1, 1000 do
  415.             effect3.CFrame = ts.CFrame
  416.             effect3.Size = effect3.Size:lerp(v3(50, 50, 50), 0.015)
  417.             effect3.Transparency = effect3.Transparency + 0.010
  418.             if effect3.Transparency >= 1 then
  419.                 effect3:Destroy()
  420.             end
  421.             swait()
  422.         end
  423.     end)()
  424.     for i = 1, 1000 do
  425.         effect2.CFrame = ts.CFrame
  426.         effect2.Size = effect2.Size:lerp(v3(0, 0, 0), 0.015)
  427.         effect2.Transparency = effect2.Transparency + 0.015
  428.         if effect2.Transparency >= 1 then
  429.             effect2:Destroy()
  430.         end
  431.         swait()
  432.     end
  433.     end)()
  434.     wait(1.5) -- cooldown
  435.     cooldown = true
  436. end
  437.  
  438. function timeresume()
  439.     coroutine.wrap(function()
  440.     sound(TimeStopSounds.TimeResume, ts, 5, 1, 0.15)
  441.     coroutine.wrap(function()
  442.         for i = 1, 10 do
  443.             camshake(20, 0.3)
  444.  
  445.             swait(5)
  446.         end
  447.  
  448.     end)()
  449.     coroutine.wrap(function()
  450.         wait(1.5)
  451.     for i,v in pairs(unfreeze) do
  452.         pcall(function()
  453.             v.Anchored = false
  454.         end)
  455.         pcall(function()
  456.             v:Resume()
  457.         end)
  458.     end
  459.     for i,v in pairs(connect) do
  460.         pcall(function()
  461.             v:Disconnect()
  462.         end)
  463.     end
  464.     for i,v in pairs(health) do
  465.         pcall(function()
  466.             local humanoid = v.humanoid
  467.             humanoid.Health = humanoid.Health - v.change
  468.             if humanoid.Parent:FindFirstChild('Health') then
  469.                 pcall(function()
  470.                     humanoid.Parent.Health.Disabled = false
  471.                 end)
  472.             end
  473.         end)
  474.     end
  475.     pcall(function()
  476.         ee:Disconnect()
  477.     end)
  478.     health = {}
  479.     unfreeze = {}
  480.     end)()
  481.     cantimestop = true
  482.     end)()
  483.     wait(1.5) -- cooldown
  484.     cooldown = false
  485. end
  486.  
  487. mouse.KeyDown:connect(function(key)
  488.     if str.lower(key) == 'r' and cantimestop and cooldown == false then
  489.         timestop()
  490.     elseif str.lower(key) == 'r' and cantimestop == false and cooldown then
  491.         timeresume()
  492.     end
  493. end)
Add Comment
Please, Sign In to add comment