View difference between Paste ID: msr8augw and QH6RwGSa
SHOW: | | - or go back to the newest paste.
1-
1+
--https://github.com/Mokiros/roblox-FE-compatibility
2-
me = game.Players.LocalPlayer
2+
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
3
local Player,Mouse,mouse,UserInputService,ContextActionService = owner
4
local RealPlayer = Player
5
do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end me = game.Players.LocalPlayer
6
h = Instance.new("HopperBin")
7
h.Parent = me.Backpack
8
h.Name = "Bridge Tool"
9
bridges = {}
10
hold = false
11
using = false
12
holdkey = false
13
polesize = 5
14
function selected(mouse, key)
15
	mouse.Button1Down:connect(function()
16
		if mouse.Target == nil then return end
17
		if using == true then return end
18
		using = true
19
		hold = true
20
		pos = mouse.Hit.p
21
		p = Instance.new("Part")
22
		p.Parent = workspace
23
		p.formFactor = 0
24
		p.Size = Vector3.new(5,1,1)
25
		p.Anchored = true
26
		p.Transparency = 0.6
27
		p.TopSurface = 0
28
		p.BrickColor = BrickColor.new("Brown")
29
		p.BottomSurface = 0
30
		p.CFrame = CFrame.new(pos)
31
		mes = Instance.new("SpecialMesh")
32
		mes.Parent = p
33
		mes.MeshType = "Brick"
34
		mes.Scale = Vector3.new(1,1,1)
35
		table.insert(bridges, p)
36
		mouse.Move:connect(function()
37
			if mouse.Target == nil then return end
38
			if hold == true then
39
				local dist = (p.Position - mouse.Hit.p).magnitude
40
				p.CFrame = CFrame.new((mouse.Hit.p + pos)/2, pos)
41
				mes.Scale = Vector3.new(1,1,dist*2)
42
			end
43
		end)
44
	end)
45
	mouse.Button1Up:connect(function()
46
		hold = false
47
		local duh = p.CFrame
48
		p.Size = Vector3.new(5,1,mes.Scale.Z)
49
		p.CFrame = duh
50
		mes:remove()
51
		for i=1, 5 do
52
			wait()
53
			p.Transparency = p.Transparency - 0.12
54
		end
55
		p.Material = "Wood"
56
		using = false
57
	end)
58
	mouse.KeyDown:connect(function(key)
59
		key = key:lower()
60
		if (key == "r") then
61
			for i=1, #bridges do
62
				bridges[i]:remove()
63
			end
64
		elseif (key == "q") then
65
			polesize = polesize - 1
66
			local ms = Instance.new("Message")
67
			ms.Parent = me
68
			ms.Text = "Pole size decreased to "..polesize
69
			wait(0.4)
70
			ms:remove()
71
		elseif (key == "e") then
72
			polesize = polesize + 1
73
			local ms = Instance.new("Message")
74
			ms.Parent = me
75
			ms.Text = "Pole size increased to "..polesize
76
			wait(0.4)
77
			ms:remove()
78
		elseif (key == "f") then
79
			if mouse.Target == nil then return end
80
			if using == true then return end
81
			using = true
82
			holdkey = true
83
			po = Instance.new("Part")
84
			po.Parent = workspace
85
			po.formFactor = 0
86
			po.Size = Vector3.new(1,1,1)
87
			po.Anchored = true
88
			po.Transparency = 0.5
89
			po.TopSurface = 0
90
			po.BrickColor = BrickColor.new("Brown")
91
			po.BottomSurface = 0
92
			mesh = Instance.new("SpecialMesh")
93
			mesh.Parent = po
94
			mesh.Scale = Vector3.new(1,polesize,1)
95
			po.CFrame = CFrame.new(mouse.Hit.p.X, mouse.Hit.p.Y + mesh.Scale.Y/2, mouse.Hit.p.Z)
96
			table.insert(bridges,po)
97
		end
98
	end)
99
	mouse.KeyUp:connect(function(key)
100
		key = key:lower()
101
		if (key == "f") then
102
			holdkey = false
103
			for i=1, 5 do
104
				wait()
105
				po.Transparency = po.Transparency - 0.1
106
			end
107
			local posi = po.CFrame
108
			po.Material = "Wood"
109
			po.Size = mesh.Scale
110
			mesh:remove()
111
			po.CFrame = posi
112
			using = false
113
		end
114
	end)
115
end
116
function deselected()
117
end
118
h.Selected:connect(selected)
119
h.Deselected:connect(deselected)