View difference between Paste ID: vtiNEg15 and UixHy3mr
SHOW: | | - or go back to the newest paste.
1
--https://github.com/Mokiros/roblox-FE-compatibility
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,game,owner = owner,game
4
local RealPlayer = Player
5
do
6
	print("FE Compatibility code V2 by Mokiros")
7
	local RealPlayer = RealPlayer
8
	script.Parent = RealPlayer.Character
9
10
	--Fake event to make stuff like Mouse.KeyDown work
11
	local Disconnect_Function = function(this)
12
		this[1].Functions[this[2]] = nil
13
	end
14
	local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
15
	local FakeEvent_Metatable = {__index={
16
		Connect = function(this,f)
17
			local i = tostring(math.random(0,10000))
18
			while this.Functions[i] do
19
				i = tostring(math.random(0,10000))
20
			end
21
			this.Functions[i] = f
22
			return setmetatable({this,i},Disconnect_Metatable)
23
		end
24
	}}
25
	FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
26
	local function fakeEvent()
27
		return setmetatable({Functions={}},FakeEvent_Metatable)
28
	end
29
30
	--Creating fake input objects with fake variables
31
    local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
32
    FakeMouse.keyUp = FakeMouse.KeyUp
33
    FakeMouse.keyDown = FakeMouse.KeyDown
34
	local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
35
	local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
36
		CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
37
	end}
38
	--Merged 2 functions into one by checking amount of arguments
39
	CAS.UnbindAction = CAS.BindAction
40
41
	--This function will trigger the events that have been :Connect()'ed
42
	local function TriggerEvent(self,ev,...)
43
		for _,f in pairs(self[ev].Functions) do
44
			f(...)
45
		end
46
	end
47
	FakeMouse.TriggerEvent = TriggerEvent
48
	UIS.TriggerEvent = TriggerEvent
49
50
	--Client communication
51
	local Event = Instance.new("RemoteEvent")
52
	Event.Name = "UserInput_Event"
53
	Event.OnServerEvent:Connect(function(plr,io)
54
	    if plr~=RealPlayer then return end
55
		FakeMouse.Target = io.Target
56
		FakeMouse.Hit = io.Hit
57
		if not io.isMouse then
58
			local b = io.UserInputState == Enum.UserInputState.Begin
59
			if io.UserInputType == Enum.UserInputType.MouseButton1 then
60
				return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
61
			end
62
			if io.UserInputType == Enum.UserInputType.MouseButton2 then
63
				return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
64
			end
65
			for _,t in pairs(CAS.Actions) do
66
				for _,k in pairs(t.Keys) do
67
					if k==io.KeyCode then
68
						t.Function(t.Name,io.UserInputState,io)
69
					end
70
				end
71
			end
72
			FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
73
			UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
74
	    end
75
	end)
76
	Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
77
	local Mouse = owner:GetMouse()
78
	local UIS = game:GetService("UserInputService")
79
	local input = function(io,RobloxHandled)
80
		if RobloxHandled then return end
81
		--Since InputObject is a client-side instance, we create and pass table instead
82
		Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
83
	end
84
	UIS.InputBegan:Connect(input)
85
	UIS.InputEnded:Connect(input)
86
	local h,t
87
	--Give the server mouse data every second frame, but only if the values changed
88
	--If player is not moving their mouse, client won't fire events
89
	local HB = game:GetService("RunService").Heartbeat
90
	while true do
91
		if h~=Mouse.Hit or t~=Mouse.Target then
92
			h,t=Mouse.Hit,Mouse.Target
93
			Event:FireServer({isMouse=true,Target=t,Hit=h})
94
		end
95
		--Wait 2 frames
96
		for i=1,2 do
97
			HB:Wait()
98
		end
99
	end]==],script)
100
101
	----Sandboxed game object that allows the usage of client-side methods and services
102
	--Real game object
103
	local RealGame = game
104
105
	--Metatable for fake service
106
	local FakeService_Metatable = {
107
		__index = function(self,k)
108
			local s = rawget(self,"_RealService")
109
			if s then
110
				return typeof(s[k])=="function"
111
				and function(_,...)return s[k](s,...)end or s[k]
112
			end
113
		end,
114
		__newindex = function(self,k,v)
115
			local s = rawget(self,"_RealService")
116
			if s then s[k]=v end
117
		end
118
	}
119
	local function FakeService(t,RealService)
120
		t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
121
		return setmetatable(t,FakeService_Metatable)
122
	end
123
124
	--Fake game object
125
	local FakeGame = {
126
		GetService = function(self,s)
127
			return rawget(self,s) or RealGame:GetService(s)
128
		end,
129
		Players = FakeService({
130
			LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
131
		},"Players"),
132
		UserInputService = FakeService(UIS,"UserInputService"),
133
		ContextActionService = FakeService(CAS,"ContextActionService"),
134
		RunService = FakeService({
135
			_btrs = {},
136
			RenderStepped = RealGame:GetService("RunService").Heartbeat,
137
			BindToRenderStep = function(self,name,_,fun)
138
				self._btrs[name] = self.Heartbeat:Connect(fun)
139
			end,
140
			UnbindFromRenderStep = function(self,name)
141
				self._btrs[name]:Disconnect()
142
			end,
143
		},"RunService")
144
	}
145
	rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
146
	FakeGame.service = FakeGame.GetService
147
	FakeService(FakeGame,game)
148
	--Changing owner to fake player object to support owner:GetMouse()
149
	game,owner = FakeGame,FakeGame.Players.LocalPlayer
150
end
151
152
local Player = game:GetService("Players").LocalPlayer
153
local Character = Player.Character
154
local Mouse = Player:GetMouse()
155
--Mouse.TargetFilter = workspace
156
157
local Head = Character:WaitForChild("Head")
158
local Torso = Character:WaitForChild("Torso")
159
local RootPart = Character:WaitForChild("HumanoidRootPart")
160
local Human = Character:WaitForChild("Humanoid")
161
162
Human.AutoRotate = false
163
Human.JumpPower = 0
164
Human.WalkSpeed = 12
165
166
-----------------------------------------------------------------------------------------------------------------------
167
168
for _, Item in next, Character:GetChildren() do
169
	if Item:IsA("CharacterAppearance") then
170
		Item:Destroy()
171
	end
172
end
173
174
local Pants = Character:FindFirstChild("Pants") or Instance.new("Pants")
175
Pants.PantsTemplate = "rbxassetid://69232474"
176
Pants.Name = "Pants"
177
Pants.Parent = Character
178
179
local Shirt = Character:FindFirstChild("Shirt") or Instance.new("Shirt")
180
Shirt.ShirtTemplate = "rbxassetid://69232183"
181
Shirt.Name = "Shirt"
182
Shirt.Parent = Character
183
184
local Face = Head:WaitForChild("face")
185
Face.Texture = "rbxassetid://112805849"
186
187
local TShirt = Torso:FindFirstChild("roblox")
188
if TShirt then
189
	TShirt:Destroy()
190
end
191
192
--[[local BodyColors = Character:WaitForChild("Body Colors")
193
BodyColors.HeadColor = BrickColor.new("Light orange")
194
BodyColors.LeftArmColor = BrickColor.new("Light orange")
195
BodyColors.RightArmColor = BrickColor.new("Light orange")
196
BodyColors.TorsoColor = BrickColor.new("Light orange")--]]
197
198
spawn(function() wait(.5)
199
	Head.BrickColor = BrickColor.new("Light orange")
200
	Torso.BrickColor = BrickColor.new("Light orange")
201
	Character["Left Arm"].BrickColor = BrickColor.new("Light orange")
202
	Character["Right Arm"].BrickColor = BrickColor.new("Light orange")
203
end)
204
205
Character:WaitForChild("Animate"):Destroy()
206
207
local RJ = RootPart:WaitForChild("RootJoint")
208
RJ:Destroy()
209
RJ = Instance.new("Weld", RootPart)
210
RJ.Part0 = RootPart
211
RJ.Part1 = Torso
212
213
local Neck = Instance.new("Weld", Torso)
214
Neck.Part0 = Torso
215
Neck.Part1 = Character:WaitForChild("Head")
216
Neck.C0 = CFrame.new(0, 1.5, 0)
217
218
Torso:WaitForChild("Right Shoulder").Part1 = nil
219
local RS = Instance.new("Weld", Head)
220
RS.Part0 = Head
221
RS.Part1 = Character:WaitForChild("Right Arm")
222
223
Torso:WaitForChild("Left Shoulder").Part1 = nil
224
local LS = Instance.new("Weld", Head)
225
LS.Part0 = Head
226
LS.Part1 = Character:WaitForChild("Left Arm")
227
228
local LH = Torso:WaitForChild("Left Hip")
229
LH:Destroy()
230
LH = Instance.new("Weld", Torso)
231
LH.Part0 = Torso
232
LH.Part1 = Character:WaitForChild("Left Leg")
233
234
local RH = Torso:WaitForChild("Right Hip")
235
RH:Destroy()
236
RH = Instance.new("Weld", Torso)
237
RH.Part0 = Torso
238
RH.Part1 = Character:WaitForChild("Right Leg")
239
240
local GUN = Instance.new("Part", Character)
241
GUN.CanCollide = false
242
GUN.Size = Vector3.new(1.549, 2.302, 3.814)
243
GUN.Name = "Handle"
244
GUN.Material = Enum.Material.SmoothPlastic
245
246
local MS = Instance.new("SpecialMesh", GUN)
247
MS.MeshType = Enum.MeshType.FileMesh
248
MS.MeshId = "rbxassetid://450812185"
249
MS.TextureId = "rbxassetid://450812194"
250
251
local GRIP = Instance.new("Weld", RS.Part1)
252
GRIP.Part0 = RS.Part1
253
GRIP.Part1 = GUN
254
255
local SN = Instance.new("Sound", GUN)
256
SN.SoundId = "rbxassetid://341294387"
257
SN.PlaybackSpeed = 0.9
258
SN.Looped = true
259
SN.Volume = 0
260
SN:Play()
261
262
local FL = Instance.new("Part", GUN)
263
FL.BrickColor = BrickColor.Yellow()
264
FL.Transparency = 1
265
FL.Material = Enum.Material.SmoothPlastic
266
FL.CanCollide = false
267
FL.Size = Vector3.new(1, 3.38, 1)
268
269
local MS2 = Instance.new("SpecialMesh", FL)
270
MS2.MeshType = Enum.MeshType.FileMesh
271
MS2.MeshId = "rbxassetid://1323306"
272
MS2.Scale = Vector3.new(0.35, 1.9, 0.35)
273
274
local FLW = Instance.new("Weld", GUN)
275
FLW.Part0 = GUN
276
FLW.Part1 = FL
277
FLW.C0 = CFrame.new(0.293, 0.251, 3.221, 0, 0.028, 1, 1, 0, 0, 0, 1, -0.028)
278
279
-----------------------------------------------------------------------------------------------------------------------
280
281
local STANCE = {
282
	NK = CFrame.new(0, 1, 0, 0.747311652, 0, 0.664473772, 0, 1, 0, -0.664473772, 0, 0.747311652);
283
	RJ = CFrame.new(0, 0, 0, 0.747311592, 0, -0.664473712, 0, 1, 0, 0.664473712, 0, 0.747311592);
284
	LS = CFrame.new(0.474761963, -1.61745477, -1.20455933, -0.127145067, -0.88503027, -0.447834671, -0.836402416, 0.338357687, -0.431213528, 0.533165276, 0.319743276, -0.783262014);
285
	RS = CFrame.new(1.14480591, -1.47239065, 0.695491791, 0.972185493, -0.190045089, -0.136889026, 0.123703048, 0.912935674, -0.388903707, 0.198880106, 0.361152887, 0.911051929);
286
	GRIP = CFrame.new(-0.0976009369, -1.92251587, -1.31733322, -0.980839312, 0.117544398, -0.155363142, 0.158846945, 0.944226265, -0.288452089, 0.11279203, -0.307604104, -0.944805682);
287
}
288
289
LS.C0 = STANCE.LS
290
RS.C0 = STANCE.RS
291
RJ.C0 = STANCE.RJ
292
GRIP.C0 = STANCE.GRIP
293
294
local Down = false
295
296
Mouse.Button1Down:Connect(function()
297
	Down = true
298
end)
299
300
Mouse.Button1Up:Connect(function()
301
	Down = false
302
end)
303
304
math.randomseed(os.time())
305
306
local function Taunt()
307
	local Taunts = {137542750, 130774824, 130776108, 679798995, 679798810}
308
	local Sound = Instance.new("Sound", GUN)
309
	local Id = Taunts[math.random(#Taunts)]
310
	Sound.TimePosition = Id == 130776108 and 4.2 or 0
311
	Sound.SoundId = "rbxassetid://" .. Id
312
	Sound.Volume = 1
313
	Sound.Ended:Connect(function()
314
		Sound:Destroy()
315
	end)
316
	Sound:Play()
317
end
318
319
Mouse.KeyDown:Connect(function(Key)
320
	if Key == string.char(32) then
321
		Taunt()
322
	end
323
end)
324
325
326
327
local function Shoot()
328
	local Bullet = Instance.new("Part")
329
	Bullet.Size = Vector3.new(0.3, 0.3, 0.7)
330
	Bullet.Transparency = 1
331
	Bullet.CanCollide = false
332
	
333
	local AntiGravity = Instance.new("BodyForce", Bullet)
334
	AntiGravity.Force = Vector3.new(0, Bullet:GetMass() * workspace.Gravity, 0)
335
	
336
	local Start = (GUN.CFrame * CFrame.new(0.255, 0.251, 1.877)).p
337
	Bullet.CFrame = CFrame.new(Start, Mouse.Hit.p)
338
	Bullet.Velocity = Bullet.CFrame.lookVector * 300
339
	
340
	Bullet.Touched:Connect(function(Hit)
341
		if Hit.Parent and Hit.Parent ~= Character and Hit.Parent:FindFirstChild("Humanoid") then
342
			Hit.Parent.Humanoid:TakeDamage(5)
343
			Bullet:Destroy()
344
		end
345
	end)
346
	
347
	Bullet.Parent = workspace
348
	game.Debris:AddItem(Bullet, 3)
349
end
350
351
352
game:GetService("RunService"):BindToRenderStep("Invisible", Enum.RenderPriority.Character.Value - 1, function()
353
	GUN.LocalTransparencyModifier = 0
354
	FL.LocalTransparencyModifier = 0
355
	LS.Part1.LocalTransparencyModifier = 0
356
	RS.Part1.LocalTransparencyModifier = 0
357
end)
358
359
local Heartbeat, Angle = game:GetService("RunService").Heartbeat
360
361
while Heartbeat:Wait() do
362
	local Angle = tick() * 8
363
		
364
	-- Torso lean
365
	local VelocityForTilt = RootPart.Velocity * Vector3.new(1, 0, 1) / 150
366
   	local VectorForTilt = RootPart.CFrame:vectorToObjectSpace(VelocityForTilt)
367
   	RJ.C0 = RJ.C0:Lerp(STANCE.RJ * CFrame.Angles(VectorForTilt.Z, VectorForTilt.X, -VectorForTilt.X), 0.1)
368
369
	-- Rotate to face camera
370
	local RootPosition = RootPart.Position
371
	local Direction = Mouse.Hit.p - RootPosition
372
	Direction = Vector3.new(Direction.X, 0, Direction.Z).unit
373
	local NewCFrame = CFrame.new(RootPosition, RootPosition + Direction) * CFrame.Angles(0, -0.02, 0)
374
	RootPart.CFrame = RootPart.CFrame:Lerp(NewCFrame, 0.1)
375
	
376
	-- Neck Angle
377
	local Hypotenuse = (Mouse.Hit.p - Head.Position).magnitude
378
	local Opposite = Mouse.Hit.p.y - Head.Position.y
379
	local Pitch = math.asin(Opposite / Hypotenuse)
380
	local NewNeckCFrame = STANCE.NK * CFrame.Angles(Pitch + 0.2, 0, 0) * CFrame.new(0, 0.5, 0)
381
	Neck.C0 = Neck.C0:Lerp(NewNeckCFrame, 0.1)
382
	
383
	-- Legs
384
	local FlatVelocity = (Torso.Velocity * Vector3.new(1, 0, 1))
385
	if FlatVelocity.magnitude < 2 then
386
		LH.C0 = LH.C0:Lerp(CFrame.new(-0.5, -1, 0) * CFrame.Angles(math.sin(tick() * 0.5) / 17, 0, -0.02 + math.sin(tick() * 0.4) / 19) * CFrame.new(0, -1, 0), 0.2)
387
		RH.C0 = RH.C0:Lerp(CFrame.new(0.5, -1, 0) * CFrame.Angles(math.sin(-tick() * 0.5) / 18, 0, 0.02 + math.sin(-tick() * 0.35) / 20) * CFrame.new(0, -1, 0), 0.2)
388
	else
389
		local Look = (Torso.CFrame.lookVector * Vector3.new(1, 0, 1)).unit
390
		local Move = FlatVelocity.unit
391
		local OffAngle = (Look:Cross(Move).Y > 0 and 1 or -1) * math.acos(1 - (Look - Move).magnitude ^ 2 / 2)
392
		OffAngle = math.max(-math.pi, math.min(math.pi, OffAngle))	
393
		LH.C0 = LH.C0:Lerp(CFrame.new(-0.5, 0, 0) * CFrame.Angles(0, OffAngle, 0)
394
		  * CFrame.new(0, -math.max(0, math.cos(Angle * 2) / 5) + math.max(0, math.cos(Angle + math.pi) / 2.5) - 2, math.sin(-Angle + math.pi) / 1.8 + 0.15)
395
		  * CFrame.Angles(math.sin(-Angle) / 1.8 - 0.2, 0, 0), 0.2)
396
		RH.C0 = RH.C0:Lerp(CFrame.new(0.5, 0, 0) * CFrame.Angles(0, OffAngle, 0)
397
		  * CFrame.new(0, -math.max(0, math.cos(Angle * 2) / 5) + math.max(0, math.cos(Angle) / 2.5) - 2, math.sin(-Angle) / 1.8 + 0.15) 
398
		  * CFrame.Angles(math.sin(Angle) / 1.8 - 0.2, 0, 0), 0.2)
399
	end
400
	
401
	-- Shooting
402
	if Down then
403
		SN.Volume = SN.Volume + (1.5 - SN.Volume) * 0.3
404
		FL.Transparency = FL.Transparency + (0.6 - FL.Transparency) * 0.2
405
		FLW.C0 = FLW.C0 * CFrame.Angles(0, 0.2, 0)
406
		Shoot()
407
	else
408
		SN.Volume = SN.Volume + (0 - SN.Volume) * 0.15
409
		FL.Transparency = FL.Transparency + (1 - FL.Transparency) * 0.2
410
	end
411
end