View difference between Paste ID: eRKK4qZV and 0hc4PHnt
SHOW: | | - or go back to the newest paste.
1
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2
local Player,game,owner = owner,game
3
local RealPlayer = Player
4
do
5
	print("FE Compatibility code by Mokiros")
6
	local rp = RealPlayer
7
	script.Parent = rp.Character
8
	
9
	--RemoteEvent for communicating
10
	local Event = Instance.new("RemoteEvent")
11
	Event.Name = "UserInput_Event"
12
13
	--Fake event to make stuff like Mouse.KeyDown work
14
	local function fakeEvent()
15
		local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
16
		t.connect = t.Connect
17
		return t
18
	end
19
20
	--Creating fake input objects with fake variables
21
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
22
	local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
23
	local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
24
		CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
25
	end}
26
	--Merged 2 functions into one by checking amount of arguments
27
	CAS.UnbindAction = CAS.BindAction
28
29
	--This function will trigger the events that have been :Connect()'ed
30
	local function te(self,ev,...)
31
		local t = m[ev]
32
		if t and t._fakeEvent then
33
			for _,f in pairs(t.Functions) do
34
				f(...)
35
			end
36
		end
37
	end
38
	m.TrigEvent = te
39
	UIS.TrigEvent = te
40
41
	Event.OnServerEvent:Connect(function(plr,io)
42
	    if plr~=rp then return end
43
		m.Target = io.Target
44
		m.Hit = io.Hit
45
		if not io.isMouse then
46
			local b = io.UserInputState == Enum.UserInputState.Begin
47
			if io.UserInputType == Enum.UserInputType.MouseButton1 then
48
				return m:TrigEvent(b and "Button1Down" or "Button1Up")
49
			end
50
			if io.UserInputType == Enum.UserInputType.MouseButton2 then
51
				return m:TrigEvent(b and "Button2Down" or "Button2Up")
52
			end
53
			for _,t in pairs(CAS.Actions) do
54
				for _,k in pairs(t.Keys) do
55
					if k==io.KeyCode then
56
						t.Function(t.Name,io.UserInputState,io)
57
					end
58
				end
59
			end
60
			m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
61
			UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
62
	    end
63
	end)
64
	Event.Parent = NLS([==[
65
	local Player = game:GetService("Players").LocalPlayer
66
	local Event = script:WaitForChild("UserInput_Event")
67
	local Mouse = Player:GetMouse()
68
	local UIS = game:GetService("UserInputService")
69
	local input = function(io,a)
70
		if a then return end
71
		--Since InputObject is a client-side instance, we create and pass table instead
72
		Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
73
	end
74
	UIS.InputBegan:Connect(input)
75
	UIS.InputEnded:Connect(input)
76
	local h,t
77
	--Give the server mouse data 30 times every second, but only if the values changed
78
	--If player is not moving their mouse, client won't fire events
79
	while wait(1/30) do
80
		if h~=Mouse.Hit or t~=Mouse.Target then
81
			h,t=Mouse.Hit,Mouse.Target
82
			Event:FireServer({isMouse=true,Target=t,Hit=h})
83
		end
84
	end]==],Player.Character)
85
86
	----Sandboxed game object that allows the usage of client-side methods and services
87
	--Real game object
88
	local _rg = game
89
90
	--Metatable for fake service
91
	local fsmt = {
92
		__index = function(self,k)
93
			local s = rawget(self,"_RealService")
94
			if s then
95
				return typeof(s[k])=="function"
96
				and function(_,...)return s[k](s,...)end or s[k]
97
			end
98
		end,
99
		__newindex = function(self,k,v)
100
			local s = rawget(self,"_RealService")
101
			if s then s[k]=v end
102
		end
103
	}
104
	local function FakeService(t,RealService)
105
		t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
106
		return setmetatable(t,fsmt)
107
	end
108
109
	--Fake game object
110
	local g = {
111
		GetService = function(self,s)
112
			return rawget(self,s) or _rg:GetService(s)
113
		end,
114
		Players = FakeService({
115
			LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
116
		},"Players"),
117
		UserInputService = FakeService(UIS,"UserInputService"),
118
		ContextActionService = FakeService(CAS,"ContextActionService"),
119
		RunService = FakeService({
120
			_btrs = {},
121
			RenderStepped = _rg:GetService("RunService").Heartbeat,
122
			BindToRenderStep = function(self,name,_,fun)
123
				self._btrs[name] = self.Heartbeat:Connect(fun)
124
			end,
125
			UnbindFromRenderStep = function(self,name)
126
				self._btrs[name]:Disconnect()
127
			end,
128
		},"RunService")
129
	}
130
	rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
131
	g.service = g.GetService
132
	FakeService(g,game)
133
	--Changing owner to fake player object to support owner:GetMouse()
134
	game,owner = g,g.Players.LocalPlayer
135
end
136
137
--Ragdoll death script by Rufus14 (pure copy paste from my bow)
138
function ragdollkill(character)
139
	local victimshumanoid = character:findFirstChildOfClass("Humanoid")
140
	if not character:findFirstChild("UpperTorso") then
141
		character.Archivable = true
142
		for i,v in pairs(character:GetChildren()) do
143
			if v.ClassName == "Sound" then
144
				v:remove()
145
			end
146
			for q,w in pairs(v:GetChildren()) do
147
				if w.ClassName == "Sound" then
148
					w:remove()
149
				end
150
			end
151
		end
152
stand2 = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
153
stand2.SoundId = "rbxassetid://3168463046"
154
stand2.Volume = 10
155
		local ragdoll = character:Clone()
156
		ragdoll:findFirstChildOfClass("Humanoid").Health = 0
157
		if ragdoll:findFirstChild("Health") then
158
			if ragdoll:findFirstChild("Health").ClassName == "Script" then
159
				ragdoll:findFirstChild("Health").Disabled = true
160
			end
161
		end
162
		for i,v in pairs(character:GetChildren()) do
163
			if v.ClassName == "Part" or v.ClassName == "ForceField" or v.ClassName == "Accessory" or v.ClassName == "Hat" then
164
				v:destroy()
165
			end
166
		end
167
		for i,v in pairs(character:GetChildren()) do
168
			if v.ClassName == "Accessory" then
169
				local attachment1 = v.Handle:findFirstChildOfClass("Attachment")
170
				if attachment1 then
171
					for q,w in pairs(character:GetChildren()) do
172
						if w.ClassName == "Part" then
173
							local attachment2 = w:findFirstChild(attachment1.Name)
174
							if attachment2 then
175
								local hinge = Instance.new("HingeConstraint", v.Handle)
176
								hinge.Attachment0 = attachment1
177
								hinge.Attachment1 = attachment2
178
								hinge.LimitsEnabled = true
179
								hinge.LowerAngle = 0
180
								hinge.UpperAngle = 0
181
							end
182
						end
183
					end
184
				end
185
			end
186
		end
187
		ragdoll.Parent = workspace
188
		if ragdoll:findFirstChild("Right Arm") then
189
			local glue = Instance.new("Glue", ragdoll.Torso)
190
			glue.Part0 = ragdoll.Torso
191
			glue.Part1 = ragdoll:findFirstChild("Right Arm")
192
			glue.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
193
			glue.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
194
			local limbcollider = Instance.new("Part", ragdoll:findFirstChild("Right Arm"))
195
			limbcollider.Size = Vector3.new(1.4,1,1)
196
			limbcollider.Shape = "Cylinder"
197
			limbcollider.Transparency = 1
198
			limbcollider.Name = "LimbCollider"
199
			local limbcolliderweld = Instance.new("Weld", limbcollider)
200
			limbcolliderweld.Part0 = ragdoll:findFirstChild("Right Arm")
201
			limbcolliderweld.Part1 = limbcollider
202
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.3,0,0)
203
		end
204
		if ragdoll:findFirstChild("Left Arm") then
205
			local glue = Instance.new("Glue", ragdoll.Torso)
206
			glue.Part0 = ragdoll.Torso
207
			glue.Part1 = ragdoll:findFirstChild("Left Arm")
208
			glue.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
209
			glue.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
210
			local limbcollider = Instance.new("Part", ragdoll:findFirstChild("Left Arm"))
211
			limbcollider.Size = Vector3.new(1.4,1,1)
212
			limbcollider.Shape = "Cylinder"
213
			limbcollider.Name = "LimbCollider"
214
			limbcollider.Transparency = 1
215
			local limbcolliderweld = Instance.new("Weld", limbcollider)
216
			limbcolliderweld.Part0 = ragdoll:findFirstChild("Left Arm")
217
			limbcolliderweld.Part1 = limbcollider
218
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.3,0,0)
219
		end
220
		if ragdoll:findFirstChild("Left Leg") then
221
			local glue = Instance.new("Glue", ragdoll.Torso)
222
			glue.Part0 = ragdoll.Torso
223
			glue.Part1 = ragdoll:findFirstChild("Left Leg")
224
			glue.C0 = CFrame.new(-0.5, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
225
			glue.C1 = CFrame.new(-0, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
226
			local limbcollider = Instance.new("Part", ragdoll:findFirstChild("Left Leg"))
227
			limbcollider.Size = Vector3.new(1.4,1,1)
228
			limbcollider.Shape = "Cylinder"
229
			limbcollider.Name = "LimbCollider"
230
			limbcollider.Transparency = 1
231
			local limbcolliderweld = Instance.new("Weld", limbcollider)
232
			limbcolliderweld.Part0 = ragdoll:findFirstChild("Left Leg")
233
			limbcolliderweld.Part1 = limbcollider
234
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.3,0,0)
235
		end
236
		if ragdoll:findFirstChild("Right Leg") then
237
			local glue = Instance.new("Glue", ragdoll.Torso)
238
			glue.Part0 = ragdoll.Torso
239
			glue.Part1 = ragdoll:findFirstChild("Right Leg")
240
			glue.C0 = CFrame.new(0.5, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
241
			glue.C1 = CFrame.new(0, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
242
			local limbcollider = Instance.new("Part", ragdoll:findFirstChild("Right Leg"))
243
			limbcollider.Size = Vector3.new(1.4,1,1)
244
			limbcollider.Shape = "Cylinder"
245
			limbcollider.Name = "LimbCollider"
246
			limbcollider.Transparency = 1
247
			local limbcolliderweld = Instance.new("Weld", limbcollider)
248
			limbcolliderweld.Part0 = ragdoll:findFirstChild("Right Leg")
249
			limbcolliderweld.Part1 = limbcollider
250
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2) * CFrame.new(-0.3,0,0)
251
		end
252
		if ragdoll:findFirstChild("Head") and ragdoll.Torso:findFirstChild("NeckAttachment") then
253
			local HeadAttachment = Instance.new("Attachment", ragdoll["Head"])
254
			HeadAttachment.Position = Vector3.new(0, -0.5, 0)
255
			local connection = Instance.new('HingeConstraint', ragdoll["Head"])
256
			connection.LimitsEnabled = true
257
			connection.Attachment0 = ragdoll.Torso.NeckAttachment
258
			connection.Attachment1 = HeadAttachment
259
			connection.UpperAngle = 60
260
			connection.LowerAngle = -60
261
		elseif ragdoll:findFirstChild("Head") and not ragdoll.Torso:findFirstChild("NeckAttachment") then
262
			local hedweld = Instance.new("Weld", ragdoll.Torso)
263
			hedweld.Part0 = ragdoll.Torso
264
			hedweld.Part1 = ragdoll.Head
265
			hedweld.C0 = CFrame.new(0,1.5,0)
266
		end
267
		game.Debris:AddItem(ragdoll, 30)
268
		wait(0.7)
269
		if ragdoll:findFirstChildOfClass("Humanoid") then
270
			ragdoll:findFirstChildOfClass("Humanoid").PlatformStand = true
271
		end
272
		if ragdoll:findFirstChild("HumanoidRootPart") then
273
			ragdoll:findFirstChild("HumanoidRootPart"):destroy()
274
		end
275
	elseif character:findFirstChild("UpperTorso") then
276
		character.Archivable = true
277
		for i,v in pairs(character:GetChildren()) do
278
			if v.ClassName == "Sound" then
279
				v:remove()
280
			end
281
			for q,w in pairs(v:GetChildren()) do
282
				if w.ClassName == "Sound" then
283
					w:remove()
284
				end
285
			end
286
		end
287
		local ragdoll = character:Clone()
288
		ragdoll:findFirstChildOfClass("Humanoid").Health = 0
289
		if ragdoll:findFirstChild("Health") then
290
			if ragdoll:findFirstChild("Health").ClassName == "Script" then
291
				ragdoll:findFirstChild("Health").Disabled = true
292
			end
293
		end
294
		for i,v in pairs(character:GetChildren()) do
295
			if v.ClassName == "Part" or v.ClassName == "ForceField" or v.ClassName == "Accessory" or v.ClassName == "Hat" or v.ClassName == "MeshPart" then
296
				v:destroy()
297
			end
298
		end
299
		for i,v in pairs(character:GetChildren()) do
300
			if v.ClassName == "Accessory" then
301
				local attachment1 = v.Handle:findFirstChildOfClass("Attachment")
302
				if attachment1 then
303
					for q,w in pairs(character:GetChildren()) do
304
						if w.ClassName == "Part" or w.ClassName == "MeshPart" then
305
							local attachment2 = w:findFirstChild(attachment1.Name)
306
							if attachment2 then
307
								local hinge = Instance.new("HingeConstraint", v.Handle)
308
								hinge.Attachment0 = attachment1
309
								hinge.Attachment1 = attachment2
310
								hinge.LimitsEnabled = true
311
								hinge.LowerAngle = 0
312
								hinge.UpperAngle = 0
313
							end
314
						end
315
					end
316
				end
317
			end
318
		end
319
		ragdoll.Parent = workspace
320
		local Humanoid = ragdoll:findFirstChildOfClass("Humanoid")
321
		Humanoid.PlatformStand = true
322
		local function makeballconnections(limb, attachementone, attachmenttwo, twistlower, twistupper)
323
			local connection = Instance.new('BallSocketConstraint', limb)
324
			connection.LimitsEnabled = true
325
			connection.Attachment0 = attachementone
326
			connection.Attachment1 = attachmenttwo
327
			connection.TwistLimitsEnabled = true
328
			connection.TwistLowerAngle = twistlower
329
			connection.TwistUpperAngle = twistupper
330
			local limbcollider = Instance.new("Part", limb)
331
			limbcollider.Size = Vector3.new(0.1,1,1)
332
			limbcollider.Shape = "Cylinder"
333
			limbcollider.Transparency = 1
334
			limbcollider:BreakJoints()
335
			local limbcolliderweld = Instance.new("Weld", limbcollider)
336
			limbcolliderweld.Part0 = limb
337
			limbcolliderweld.Part1 = limbcollider
338
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2)
339
		end
340
		local function makehingeconnections(limb, attachementone, attachmenttwo, lower, upper)
341
			local connection = Instance.new('HingeConstraint', limb)
342
			connection.LimitsEnabled = true
343
			connection.Attachment0 = attachementone
344
			connection.Attachment1 = attachmenttwo
345
			connection.LimitsEnabled = true
346
			connection.LowerAngle = lower
347
			connection.UpperAngle = upper
348
			local limbcollider = Instance.new("Part", limb)
349
			limbcollider.Size = Vector3.new(0.1,1,1)
350
			limbcollider.Shape = "Cylinder"
351
			limbcollider.Transparency = 1
352
			limbcollider:BreakJoints()
353
			local limbcolliderweld = Instance.new("Weld", limbcollider)
354
			limbcolliderweld.Part0 = limb
355
			limbcolliderweld.Part1 = limbcollider
356
			limbcolliderweld.C0 = CFrame.fromEulerAnglesXYZ(0,0,math.pi/2)
357
		end
358
		local HeadAttachment = Instance.new("Attachment", Humanoid.Parent.Head)
359
		HeadAttachment.Position = Vector3.new(0, -0.5, 0)
360
		makehingeconnections(Humanoid.Parent.Head, HeadAttachment, ragdoll.UpperTorso.NeckAttachment, -50, 50)
361
		makehingeconnections(Humanoid.Parent.LowerTorso, Humanoid.Parent.LowerTorso.WaistRigAttachment, Humanoid.Parent.UpperTorso.WaistRigAttachment, -50, 50)
362
		makeballconnections(Humanoid.Parent.LeftUpperArm, Humanoid.Parent.LeftUpperArm.LeftShoulderRigAttachment, Humanoid.Parent.UpperTorso.LeftShoulderRigAttachment, -200, 200, 180)
363
		makehingeconnections(Humanoid.Parent.LeftLowerArm, Humanoid.Parent.LeftLowerArm.LeftElbowRigAttachment, Humanoid.Parent.LeftUpperArm.LeftElbowRigAttachment, 0, -60)
364
		makehingeconnections(Humanoid.Parent.LeftHand, Humanoid.Parent.LeftHand.LeftWristRigAttachment, Humanoid.Parent.LeftLowerArm.LeftWristRigAttachment, -20, 20)
365
		--
366
		makeballconnections(Humanoid.Parent.RightUpperArm, Humanoid.Parent.RightUpperArm.RightShoulderRigAttachment, Humanoid.Parent.UpperTorso.RightShoulderRigAttachment, -200, 200, 180)
367
		makehingeconnections(Humanoid.Parent.RightLowerArm, Humanoid.Parent.RightLowerArm.RightElbowRigAttachment, Humanoid.Parent.RightUpperArm.RightElbowRigAttachment, 0, -60)
368
		makehingeconnections(Humanoid.Parent.RightHand, Humanoid.Parent.RightHand.RightWristRigAttachment, Humanoid.Parent.RightLowerArm.RightWristRigAttachment, -20, 20)
369
		--
370
		makeballconnections(Humanoid.Parent.RightUpperLeg, Humanoid.Parent.RightUpperLeg.RightHipRigAttachment, Humanoid.Parent.LowerTorso.RightHipRigAttachment, -80, 80, 80)
371
		makehingeconnections(Humanoid.Parent.RightLowerLeg, Humanoid.Parent.RightLowerLeg.RightKneeRigAttachment, Humanoid.Parent.RightUpperLeg.RightKneeRigAttachment, 0, 60)
372
		makehingeconnections(Humanoid.Parent.RightFoot, Humanoid.Parent.RightFoot.RightAnkleRigAttachment, Humanoid.Parent.RightLowerLeg.RightAnkleRigAttachment, -20, 20)
373
		--
374
		makeballconnections(Humanoid.Parent.LeftUpperLeg, Humanoid.Parent.LeftUpperLeg.LeftHipRigAttachment, Humanoid.Parent.LowerTorso.LeftHipRigAttachment, -80, 80, 80)
375
		makehingeconnections(Humanoid.Parent.LeftLowerLeg, Humanoid.Parent.LeftLowerLeg.LeftKneeRigAttachment, Humanoid.Parent.LeftUpperLeg.LeftKneeRigAttachment, 0, 60)
376
		makehingeconnections(Humanoid.Parent.LeftFoot, Humanoid.Parent.LeftFoot.LeftAnkleRigAttachment, Humanoid.Parent.LeftLowerLeg.LeftAnkleRigAttachment, -20, 20)
377
		for i,v in pairs(Humanoid.Parent:GetChildren()) do
378
			if v.ClassName == "Accessory" then
379
				local attachment1 = v.Handle:findFirstChildOfClass("Attachment")
380
				if attachment1 then
381
					for q,w in pairs(Humanoid.Parent:GetChildren()) do
382
						if w.ClassName == "Part" then
383
							local attachment2 = w:findFirstChild(attachment1.Name)
384
							if attachment2 then
385
								local hinge = Instance.new("HingeConstraint", v.Handle)
386
								hinge.Attachment0 = attachment1
387
								hinge.Attachment1 = attachment2
388
								hinge.LimitsEnabled = true
389
								hinge.LowerAngle = 0
390
								hinge.UpperAngle = 0
391
							end
392
						end
393
					end
394
				end
395
			end
396
		end
397
		for i,v in pairs(ragdoll:GetChildren()) do
398
			for q,w in pairs(v:GetChildren()) do
399
				if w.ClassName == "Motor6D"--[[ and w.Name ~= "Neck"--]] then
400
					w:destroy()
401
				end
402
			end
403
		end
404
		if ragdoll:findFirstChild("HumanoidRootPart") then
405
			ragdoll.HumanoidRootPart.Anchored = true
406
			ragdoll.HumanoidRootPart.CanCollide = false
407
		end
408
		if ragdoll:findFirstChildOfClass("Humanoid") then
409
			ragdoll:findFirstChildOfClass("Humanoid").PlatformStand = true
410
		end
411
		game.Debris:AddItem(ragdoll, 30)
412
	end
413
end
414
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
415
    hit1:Play()
416
stand2:Play()
417
end)
418
function ded()
419
	owner.Character:BreakJoints()
420
	ragdollkill(owner.Character)
421
end
422
owner.Character:findFirstChildOfClass("Humanoid").Died:connect(ded)