SHOW:
|
|
- or go back to the newest paste.
1 | - | -- This script has been converted to FE by iPxter |
1 | + | |
2 | who = game.Players.LocalPlayer.Name | |
3 | players = game:GetService('Players') | |
4 | - | if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end |
4 | + | |
5 | - | local Player,Mouse,mouse,UserInputService,ContextActionService = owner |
5 | + | |
6 | - | do |
6 | + | |
7 | - | print("FE Compatibility code by Mokiros | Translated to FE by iPxter") |
7 | + | |
8 | - | script.Parent = Player.Character |
8 | + | |
9 | pcall(function() char.Barf:remove() end) | |
10 | - | --RemoteEvent for communicating |
10 | + | |
11 | - | local Event = Instance.new("RemoteEvent") |
11 | + | |
12 | - | Event.Name = "UserInput_Event" |
12 | + | |
13 | local torso = Instance.new("Part") | |
14 | - | --Fake event to make stuff like Mouse.KeyDown work |
14 | + | |
15 | - | local function fakeEvent() |
15 | + | |
16 | - | local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end} |
16 | + | |
17 | - | t.connect = t.Connect |
17 | + | |
18 | - | return t |
18 | + | |
19 | - | end |
19 | + | |
20 | torso:BreakJoints() | |
21 | - | --Creating fake input objects with fake variables |
21 | + | |
22 | - | local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()} |
22 | + | |
23 | - | local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()} |
23 | + | |
24 | - | local CAS = {Actions={},BindAction=function(self,name,fun,touch,...) |
24 | + | |
25 | - | CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil |
25 | + | |
26 | - | end} |
26 | + | |
27 | - | --Merged 2 functions into one by checking amount of arguments |
27 | + | |
28 | - | CAS.UnbindAction = CAS.BindAction |
28 | + | |
29 | torsow.Part1 = char.Torso | |
30 | - | --This function will trigger the events that have been :Connect()'ed |
30 | + | |
31 | - | local function te(self,ev,...) |
31 | + | |
32 | - | local t = m[ev] |
32 | + | |
33 | - | if t and t._fakeEvent and t.Function then |
33 | + | |
34 | - | t.Function(...) |
34 | + | |
35 | - | end |
35 | + | |
36 | - | end |
36 | + | |
37 | - | m.TrigEvent = te |
37 | + | |
38 | - | UIS.TrigEvent = te |
38 | + | |
39 | rarm.Part1 = torso | |
40 | - | Event.OnServerEvent:Connect(function(plr,io) |
40 | + | |
41 | - | if plr~=Player then return end |
41 | + | |
42 | - | if io.isMouse then |
42 | + | |
43 | - | m.Target = io.Target |
43 | + | |
44 | - | m.Hit = io.Hit |
44 | + | |
45 | - | else |
45 | + | |
46 | - | local b = io.UserInputState == Enum.UserInputState.Begin |
46 | + | |
47 | - | if io.UserInputType == Enum.UserInputType.MouseButton1 then |
47 | + | |
48 | - | return m:TrigEvent(b and "Button1Down" or "Button1Up") |
48 | + | |
49 | - | end |
49 | + | |
50 | - | for _,t in pairs(CAS.Actions) do |
50 | + | |
51 | - | for _,k in pairs(t.Keys) do |
51 | + | |
52 | - | if k==io.KeyCode then |
52 | + | |
53 | - | t.Function(t.Name,io.UserInputState,io) |
53 | + | |
54 | - | end |
54 | + | |
55 | - | end |
55 | + | |
56 | - | end |
56 | + | |
57 | - | m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower()) |
57 | + | |
58 | - | UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false) |
58 | + | |
59 | - | end |
59 | + | |
60 | - | end) |
60 | + | |
61 | - | Event.Parent = NLS([==[ |
61 | + | |
62 | - | local Player = game:GetService("Players").LocalPlayer |
62 | + | |
63 | - | local Event = script:WaitForChild("UserInput_Event") |
63 | + | |
64 | barf.CanCollide = false | |
65 | - | local UIS = game:GetService("UserInputService") |
65 | + | |
66 | - | local input = function(io,a) |
66 | + | |
67 | - | if a then return end |
67 | + | |
68 | - | --Since InputObject is a client-side instance, we create and pass table instead |
68 | + | |
69 | - | Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}) |
69 | + | |
70 | - | end |
70 | + | |
71 | - | UIS.InputBegan:Connect(input) |
71 | + | |
72 | - | UIS.InputEnded:Connect(input) |
72 | + | |
73 | wait() | |
74 | - | local Mouse = Player:GetMouse() |
74 | + | |
75 | - | local h,t |
75 | + | |
76 | - | --Give the server mouse data 30 times every second, but only if the values changed |
76 | + | |
77 | - | --If player is not moving their mouse, client won't fire events |
77 | + | |
78 | - | while wait(1/30) do |
78 | + | |
79 | - | if h~=Mouse.Hit or t~=Mouse.Target then |
79 | + | |
80 | - | h,t=Mouse.Hit,Mouse.Target |
80 | + | |
81 | - | Event:FireServer({isMouse=true,Target=t,Hit=h}) |
81 | + | |
82 | - | end |
82 | + | |
83 | - | end]==],Player.Character) |
83 | + | |
84 | - | Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS |
84 | + | |
85 | - | end |
85 | + | |
86 | end | |
87 | - | --=============== |
87 | + | |
88 | end | |
89 | end |