Advertisement
InTesting

test twice twice

Mar 3rd, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.34 KB | None | 0 0
  1. -- Instructions:
  2. --[[
  3. Any local variables with :
  4.  = LocalPlayer:
  5.     Must be replaced with "owner". So if your local variable is game.Players.LocalPlayer , replace it with owner
  6.  = :GetMouse():
  7.     Remove the variable entirely.
  8.  
  9. then paste this over the desired script
  10. --]]
  11.  
  12. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  13. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  14. do
  15.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  16.     script.Parent = Player.Character
  17.  
  18.     --RemoteEvent for communicating
  19.     local Event = Instance.new("RemoteEvent")
  20.     Event.Name = "UserInput_Event"
  21.     --Fake event to make stuff like Mouse.KeyDown work
  22.     local function fakeEvent()
  23.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  24.         t.connect = t.Connect
  25.         return t
  26.     end
  27.     --Creating fake input objects with fake variables
  28.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  29.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  30.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  31.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  32.     end}
  33.     --Merged 2 functions into one by checking amount of arguments
  34.     CAS.UnbindAction = CAS.BindAction
  35.  
  36.     --This function will trigger the events that have been :Connect()'ed
  37.     local function te(self,ev,...)
  38.         local t = m[ev]
  39.         if t and t._fakeEvent and t.Function then
  40.             t.Function(...)
  41.         end
  42.     end
  43.     m.TrigEvent = te
  44.     UIS.TrigEvent = te
  45.     Event.OnServerEvent:Connect(function(plr,io)
  46.         if plr~=Player then return end
  47.         if io.isMouse then
  48.             m.Target = io.Target
  49.             m.Hit = io.Hit
  50.         else
  51.             local b = io.UserInputState == Enum.UserInputState.Begin
  52.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  53.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  54.             end
  55.             for _,t in pairs(CAS.Actions) do
  56.                 for _,k in pairs(t.Keys) do
  57.                     if k==io.KeyCode then
  58.                         t.Function(t.Name,io.UserInputState,io)
  59.                     end
  60.                 end
  61.             end
  62.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  63.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  64.         end
  65.     end)
  66.     Event.Parent = NLS([==[
  67.     local Player = game:GetService("Players").LocalPlayer
  68.     local Event = script:WaitForChild("UserInput_Event")
  69.     local UIS = game:GetService("UserInputService")
  70.     local input = function(io,a)
  71.         if a then return end
  72.         --Since InputObject is a client-side instance, we create and pass table instead
  73.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  74.     end
  75.     UIS.InputBegan:Connect(input)
  76.     UIS.InputEnded:Connect(input)
  77.     local Mouse = Player:GetMouse()
  78.     local h,t
  79.     --Give the server mouse data 30 times every second, but only if the values changed
  80.     --If player is not moving their mouse, client won't fire events
  81.     while wait(1/30) do
  82.         if h~=Mouse.Hit or t~=Mouse.Target then
  83.             h,t=Mouse.Hit,Mouse.Target
  84.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  85.         end
  86.     end]==],Player.Character)
  87.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  88. end
  89. -- End of FE converter
  90. local char = owner.Character
  91. if char then
  92. function DeathEffect_Anchored1(TargetPlayer)
  93.     if game.Players:FindFirstChild(TargetPlayer)==nil then
  94.         print(TargetPlayer..” is not a valid argument. TargetPlayer needs to be a string and needs to exist as a player.)
  95.     else
  96.         local character = game.Players:FindFirstChild(TargetPlayer).Character
  97.         if character.Health>=0 then
  98.             local CCC = character:GetDescendants()
  99.             for _, v in pairs(CCC) do
  100.                 if v:IsA(“MeshPart”) or v:IsA(“Part”) then
  101.                     v.Anchored = true
  102.                 end
  103.             end
  104.         end
  105.     end
  106. end
  107. owner.Character.Humanoid.Died:Connect(function()
  108.     DeathEffect_Anchored1(owner.Name)
  109. end)
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement