carlosname

Untitled

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