carlosname

Untitled

May 3rd, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --By Rufus14, works on r6 aswell on r15 (WORKS ON EVERY SERVER), press z to die (RUN AS LOCAL)
  2.  
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,game,owner = owner,game
  5. local RealPlayer = Player
  6. do
  7.     print("FE Compatibility code V2 by Mokiros")
  8.     local RealPlayer = RealPlayer
  9.     script.Parent = RealPlayer.Character
  10.  
  11.     --Fake event to make stuff like Mouse.KeyDown work
  12.     local Disconnect_Function = function(this)
  13.         this[1].Functions[this[2]] = nil
  14.     end
  15.     local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  16.     local FakeEvent_Metatable = {__index={
  17.         Connect = function(this,f)
  18.             local i = tostring(math.random(0,10000))
  19.             while this.Functions[i] do
  20.                 i = tostring(math.random(0,10000))
  21.             end
  22.             this.Functions[i] = f
  23.             return setmetatable({this,i},Disconnect_Metatable)
  24.         end
  25.     }}
  26.     FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  27.     local function fakeEvent()
  28.         return setmetatable({Functions={}},FakeEvent_Metatable)
  29.     end
  30.  
  31.     --Creating fake input objects with fake variables
  32.     local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  33.     FakeMouse.keyUp = FakeMouse.KeyUp
  34.     FakeMouse.keyDown = FakeMouse.KeyDown
  35.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  36.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  37.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  38.     end}
  39.     --Merged 2 functions into one by checking amount of arguments
  40.     CAS.UnbindAction = CAS.BindAction
  41.  
  42.     --This function will trigger the events that have been :Connect()'ed
  43.     local function TriggerEvent(self,ev,...)
  44.         for _,f in pairs(self[ev].Functions) do
  45.             f(...)
  46.         end
  47.     end
  48.     FakeMouse.TriggerEvent = TriggerEvent
  49.     UIS.TriggerEvent = TriggerEvent
  50.  
  51.     --Client communication
  52.     local Event = Instance.new("RemoteEvent")
  53.     Event.Name = "UserInput_Event"
  54.     Event.OnServerEvent:Connect(function(plr,io)
  55.         if plr~=RealPlayer then return end
  56.         FakeMouse.Target = io.Target
  57.         FakeMouse.Hit = io.Hit
  58.         if not io.isMouse then
  59.             local b = io.UserInputState == Enum.UserInputState.Begin
  60.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  61.                 return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  62.             end
  63.             if io.UserInputType == Enum.UserInputType.MouseButton2 then
  64.                 return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  65.             end
  66.             for _,t in pairs(CAS.Actions) do
  67.                 for _,k in pairs(t.Keys) do
  68.                     if k==io.KeyCode then
  69.                         t.Function(t.Name,io.UserInputState,io)
  70.                     end
  71.                 end
  72.             end
  73.             FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  74.             UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  75.         end
  76.     end)
  77.     Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  78.     local Mouse = owner:GetMouse()
  79.     local UIS = game:GetService("UserInputService")
  80.     local input = function(io,RobloxHandled)
  81.         if RobloxHandled then return end
  82.         --Since InputObject is a client-side instance, we create and pass table instead
  83.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  84.     end
  85.     UIS.InputBegan:Connect(input)
  86.     UIS.InputEnded:Connect(input)
  87.     local h,t
  88.     --Give the server mouse data every second frame, but only if the values changed
  89.     --If player is not moving their mouse, client won't fire events
  90.     local HB = game:GetService("RunService").Heartbeat
  91.     while true do
  92.         if h~=Mouse.Hit or t~=Mouse.Target then
  93.             h,t=Mouse.Hit,Mouse.Target
  94.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  95.         end
  96.         --Wait 2 frames
  97.         for i=1,2 do
  98.             HB:Wait()
  99.         end
  100.     end]==],script)
  101.  
  102.     ----Sandboxed game object that allows the usage of client-side methods and services
  103.     --Real game object
  104.     local RealGame = game
  105.  
  106.     --Metatable for fake service
  107.     local FakeService_Metatable = {
  108.         __index = function(self,k)
  109.             local s = rawget(self,"_RealService")
  110.             if s then
  111.                 return typeof(s[k])=="function"
  112.                 and function(_,...)return s[k](s,...)end or s[k]
  113.             end
  114.         end,
  115.         __newindex = function(self,k,v)
  116.             local s = rawget(self,"_RealService")
  117.             if s then s[k]=v end
  118.         end
  119.     }
  120.     local function FakeService(t,RealService)
  121.         t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  122.         return setmetatable(t,FakeService_Metatable)
  123.     end
  124.  
  125.     --Fake game object
  126.     local FakeGame = {
  127.         GetService = function(self,s)
  128.             return rawget(self,s) or RealGame:GetService(s)
  129.         end,
  130.         Players = FakeService({
  131.             LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  132.         },"Players"),
  133.         UserInputService = FakeService(UIS,"UserInputService"),
  134.         ContextActionService = FakeService(CAS,"ContextActionService"),
  135.         RunService = FakeService({
  136.             _btrs = {},
  137.             RenderStepped = RealGame:GetService("RunService").Heartbeat,
  138.             BindToRenderStep = function(self,name,_,fun)
  139.                 self._btrs[name] = self.Heartbeat:Connect(fun)
  140.             end,
  141.             UnbindFromRenderStep = function(self,name)
  142.                 self._btrs[name]:Disconnect()
  143.             end,
  144.         },"RunService")
  145.     }
  146.     rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  147.     FakeGame.service = FakeGame.GetService
  148.     FakeService(FakeGame,game)
  149.     --Changing owner to fake player object to support owner:GetMouse()
  150.     game,owner = FakeGame,FakeGame.Players.LocalPlayer
  151. end
  152. character = game:GetService("Players").LocalPlayer.Character
  153. humanoid = character:findFirstChildOfClass("Humanoid")
  154. mouse = game:GetService("Players").LocalPlayer:GetMouse()
  155. canuncollide = true
  156. function die()
  157.     print("dead")
  158.     local rootcframe = character.HumanoidRootPart.CFrame
  159.     local deadsign = Instance.new("BoolValue", character)
  160.     deadsign.Name = "ImDead"
  161.     character.HumanoidRootPart:destroy()
  162.     for i,v in pairs(character:GetChildren()) do
  163.         if v.ClassName == "MeshPart" or v.ClassName == "Part" then
  164.             local position = Instance.new("CFrameValue", v)
  165.             position.Name = "LimbPosition"
  166.             position.Value = v.CFrame
  167.         end
  168.     end
  169.     if character:findFirstChild("UpperTorso") then
  170.         wait(1)
  171.     elseif character:findFirstChild("Torso") then
  172.         wait(3)
  173.     end
  174.     local function uncollide()
  175.         while game:GetService("RunService").Stepped:wait() and canuncollide do
  176.             if canuncollide then
  177.                 if character:findFirstChild("Torso") then
  178.                     character.Torso.CanCollide = false
  179.                 end
  180.             end
  181.         end
  182.     end
  183.     for i,v in pairs(character:GetChildren()) do
  184.         if v.ClassName == "MeshPart" or v.ClassName == "Part" and v:findFirstChild("LimbPosition") then
  185.             local gyro = Instance.new("BodyGyro", v)
  186.             gyro.CFrame = v.LimbPosition.Value
  187.             if v.Name == "Torso" then
  188.                 spawn(uncollide)
  189.             end
  190.             for i = 0,0.7 , 0.08 do
  191.                 v.CFrame = v.CFrame:lerp(v.LimbPosition.Value, i)
  192.                 game:GetService("RunService").RenderStepped:wait()
  193.             end
  194.             local bodypos = Instance.new("BodyPosition", v)
  195.             bodypos.Position = v.LimbPosition.Value.p
  196.             bodypos.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  197.         end
  198.     end
  199.     while game:GetService("Players").LocalPlayer.Character:findFirstChild("ImDead") do
  200.         game:GetService("RunService").RenderStepped:wait()
  201.     end
  202.     canuncollide = false
  203.     print("teleporting")
  204.     game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")
  205.     if game:GetService("Players").LocalPlayer.Character:findFirstChild("ForceField") then
  206.         game:GetService("Players").LocalPlayer.Character:findFirstChild("ForceField"):destroy()
  207.     end
  208.     for i = 1,8 do
  209.         game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame = rootcframe
  210.         wait()
  211.     end
  212. end
  213. function press(key)
  214.     key = key:lower()
  215.     if key == "z" and canuncollide then
  216.         humanoid.Health = 0
  217.     end
  218. end
  219. mouse.KeyDown:connect(press)
  220. humanoid.Died:connect(die)
Add Comment
Please, Sign In to add comment