View difference between Paste ID: dJ77TESp and Mhwus4hB
SHOW: | | - or go back to the newest paste.
1-
--https://github.com/Mokiros/roblox-FE-compatibility
1+
2-
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2+
3-
local Player,game,owner = owner,game
3+
4-
local RealPlayer = Player
4+
5-
do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
5+
6
			if k=="script" then
7
				return var
8
			else
9
				return env[k]
10
			end
11
		end,
12
	})
13
	setfenv(func,newenv)
14
	return func
15
end
16
cors = {}
17
mas = Instance.new("Model",game:GetService("Lighting"))
18
Camera0 = Instance.new("Camera")
19
Tool1 = Instance.new("Tool")
20
Part2 = Instance.new("Part")
21
Part3 = Instance.new("Part")
22
Script4 = Instance.new("Script")
23
Part5 = Instance.new("Part")
24
Script6 = Instance.new("Script")
25
Script7 = Instance.new("Script")
26
Script8 = Instance.new("Script")
27
Camera0.Parent = mas
28
Camera0.CFrame = CFrame.new(-18.7888851, 12.3762856, 46.64011, 0.658702195, 0.265955359, -0.703831851, -1.49011594e-08, 0.935444355, 0.35347423, 0.752403796, -0.232834235, 0.616179228)
29
Camera0.CoordinateFrame = CFrame.new(-18.7888851, 12.3762856, 46.64011, 0.658702195, 0.265955359, -0.703831851, -1.49011594e-08, 0.935444355, 0.35347423, 0.752403796, -0.232834235, 0.616179228)
30
Camera0.Focus = CFrame.new(-17.3812275, 11.6693401, 45.4077568, 1, 0, 0, 0, 1, 0, 0, 0, 1)
31
Camera0.focus = CFrame.new(-17.3812275, 11.6693401, 45.4077568, 1, 0, 0, 0, 1, 0, 0, 0, 1)
32
Tool1.Name = "BanHammer"
33
Tool1.Parent = mas
34
Tool1.Grip = CFrame.new(0, -0, -0, 1.19248806e-08, 0, -1, 0, 1, 0, 1, 0, 1.19248806e-08)
35
Tool1.GripForward = Vector3.new(1, -0, -1.19248806e-08)
36
Tool1.GripRight = Vector3.new(1.19248806e-08, 0, 1)
37
Part2.Name = "Handle"
38
Part2.Parent = Tool1
39
Part2.CFrame = CFrame.new(9.5, 5, 20.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
40
Part2.Position = Vector3.new(9.5, 5, 20.5)
41
Part2.Color = Color3.new(0.388235, 0.372549, 0.384314)
42
Part2.Size = Vector3.new(1, 4, 1)
43
Part2.BottomSurface = Enum.SurfaceType.Smooth
44
Part2.BrickColor = BrickColor.new("Dark stone grey")
45
Part2.TopSurface = Enum.SurfaceType.Smooth
46
Part2.brickColor = BrickColor.new("Dark stone grey")
47
Part3.Name = "BanPart"
48
Part3.Parent = Tool1
49
Part3.CFrame = CFrame.new(11.5, 8.5, 20.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
50
Part3.Position = Vector3.new(11.5, 8.5, 20.5)
51
Part3.Color = Color3.new(1, 0, 0)
52
Part3.Size = Vector3.new(1, 3, 3)
53
Part3.BottomSurface = Enum.SurfaceType.Smooth
54
Part3.BrickColor = BrickColor.new("Really red")
55
Part3.TopSurface = Enum.SurfaceType.Smooth
56
Part3.brickColor = BrickColor.new("Really red")
57
Script4.Parent = Part3
58
table.insert(cors,sandbox(Script4,function()
59
function onTouched (hit)
60
	if hit.Parent:FindFirstChild("Humanoid") then
61
		local humanoid = hit.Parent:WaitForChild("Humanoid")
62
		local playername = hit.Parent.Name
63
		local player = game.Players:FindFirstChild(playername)
64
		player:Kick("Banned by Ban Hammer!")
65
		print("The ban hammer has Banned"..playername)
66
	end
67
	
68
end
69
script.Parent.Touched:connect(onTouched)
70
end))
71
Part5.Parent = Tool1
72
Part5.CFrame = CFrame.new(9, 8.5, 20.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
73
Part5.Position = Vector3.new(9, 8.5, 20.5)
74
Part5.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
75
Part5.Size = Vector3.new(4, 3, 3)
76
Part5.BottomSurface = Enum.SurfaceType.Smooth
77
Part5.BrickColor = BrickColor.new("Really black")
78
Part5.TopSurface = Enum.SurfaceType.Smooth
79
Part5.brickColor = BrickColor.new("Really black")
80
Script6.Name = "qPerfectionWeld"
81
Script6.Parent = Tool1
82
table.insert(cors,sandbox(Script6,function()
83
-- Created by Quenty (@Quenty, follow me on twitter).
84
-- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
85
-- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
86
87
--[[ INSTRUCTIONS
88
- Place in the model
89
- Make sure model is anchored
90
- That's it. It will weld the model and all children. 
91
92
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
93
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
94
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
95
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
96
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
97
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
98
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
99
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED. 
100
101
This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes. 
102
]]
103
104
--[[ DOCUMENTATION
105
- Will work in tools. If ran more than once it will not create more than one weld.  This is especially useful for tools that are dropped and then picked up again.
106
- Will work in PBS servers
107
- Will work as long as it starts out with the part anchored
108
- Stores the relative CFrame as a CFrame value
109
- Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
110
- Utilizes a recursive algorith to find all parts in the model
111
- Will reweld on script reparent if the script is initially parented to a tool.
112
- Welds as fast as possible
113
]]
114
115
-- qPerfectionWeld.lua
116
-- Created 10/6/2014
117
-- Author: Quenty
118
-- Version 1.0.3
119
120
-- Updated 10/14/2014 - Updated to 1.0.1
121
--- Bug fix with existing ROBLOX welds ? Repro by asimo3089
122
123
-- Updated 10/14/2014 - Updated to 1.0.2
124
--- Fixed bug fix. 
125
126
-- Updated 10/14/2014 - Updated to 1.0.3
127
--- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
128
129
local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
130
131
132
local function CallOnChildren(Instance, FunctionToCall)
133
	-- Calls a function on each of the children of a certain object, using recursion.  
134
135
	FunctionToCall(Instance)
136
137
	for _, Child in next, Instance:GetChildren() do
138
		CallOnChildren(Child, FunctionToCall)
139
	end
140
end
141
142
local function GetNearestParent(Instance, ClassName)
143
	-- Returns the nearest parent of a certain class, or returns nil
144
145
	local Ancestor = Instance
146
	repeat
147
		Ancestor = Ancestor.Parent
148
		if Ancestor == nil then
149
			return nil
150
		end
151
	until Ancestor:IsA(ClassName)
152
153
	return Ancestor
154
end
155
156
local function GetBricks(StartInstance)
157
	local List = {}
158
159
	-- if StartInstance:IsA("BasePart") then
160
	-- 	List[#List+1] = StartInstance
161
	-- end
162
163
	CallOnChildren(StartInstance, function(Item)
164
		if Item:IsA("BasePart") then
165
			List[#List+1] = Item;
166
		end
167
	end)
168
169
	return List
170
end
171
172
local function Modify(Instance, Values)
173
	-- Modifies an Instance by using a table.  
174
175
	assert(type(Values) == "table", "Values is not a table");
176
177
	for Index, Value in next, Values do
178
		if type(Index) == "number" then
179
			Value.Parent = Instance
180
		else
181
			Instance[Index] = Value
182
		end
183
	end
184
	return Instance
185
end
186
187
local function Make(ClassType, Properties)
188
	-- Using a syntax hack to create a nice way to Make new items.  
189
190
	return Modify(Instance.new(ClassType), Properties)
191
end
192
193
local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
194
local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
195
196
local function HasWheelJoint(Part)
197
	for _, SurfaceName in pairs(Surfaces) do
198
		for _, HingSurfaceName in pairs(HingSurfaces) do
199
			if Part[SurfaceName].Name == HingSurfaceName then
200
				return true
201
			end
202
		end
203
	end
204
	
205
	return false
206
end
207
208
local function ShouldBreakJoints(Part)
209
	--- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
210
	--  definitely some edge cases. 
211
212
	if NEVER_BREAK_JOINTS then
213
		return false
214
	end
215
	
216
	if HasWheelJoint(Part) then
217
		return false
218
	end
219
	
220
	local Connected = Part:GetConnectedParts()
221
	
222
	if #Connected == 1 then
223
		return false
224
	end
225
	
226
	for _, Item in pairs(Connected) do
227
		if HasWheelJoint(Item) then
228
			return false
229
		elseif not Item:IsDescendantOf(script.Parent) then
230
			return false
231
		end
232
	end
233
	
234
	return true
235
end
236
237
local function WeldTogether(Part0, Part1, JointType, WeldParent)
238
	--- Weld's 2 parts together
239
	-- @param Part0 The first part
240
	-- @param Part1 The second part (Dependent part most of the time).
241
	-- @param [JointType] The type of joint. Defaults to weld.
242
	-- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
243
	-- @return The weld created.
244
245
	JointType = JointType or "Weld"
246
	local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
247
	
248
	local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
249
	Modify(NewWeld, {
250
		Name = "qCFrameWeldThingy";
251
		Part0  = Part0;
252
		Part1  = Part1;
253
		C0     = CFrame.new();--Part0.CFrame:inverse();
254
		C1     = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
255
		Parent = Part1;
256
	})
257
258
	if not RelativeValue then
259
		RelativeValue = Make("CFrameValue", {
260
			Parent     = Part1;
261
			Name       = "qRelativeCFrameWeldValue";
262
			Archivable = true;
263
			Value      = NewWeld.C1;
264
		})
265
	end
266
267
	return NewWeld
268
end
269
270
local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
271
	-- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
272
	-- @param MainPart The part to weld the model to (can be in the model).
273
	-- @param [JointType] The type of joint. Defaults to weld. 
274
	-- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
275
	
276
	for _, Part in pairs(Parts) do
277
		if ShouldBreakJoints(Part) then
278
			Part:BreakJoints()
279
		end
280
	end
281
	
282
	for _, Part in pairs(Parts) do
283
		if Part ~= MainPart then
284
			WeldTogether(MainPart, Part, JointType, MainPart)
285
		end
286
	end
287
288
	if not DoNotUnanchor then
289
		for _, Part in pairs(Parts) do
290
			Part.Anchored = false
291
		end
292
		MainPart.Anchored = false
293
	end
294
end
295
296
local function PerfectionWeld()	
297
	local Tool = GetNearestParent(script, "Tool")
298
299
	local Parts = GetBricks(script.Parent)
300
	local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
301
302
	if PrimaryPart then
303
		WeldParts(Parts, PrimaryPart, "Weld", false)
304
	else
305
		warn("qWeld - Unable to weld part")
306
	end
307
	
308
	return Tool
309
end
310
311
local Tool = PerfectionWeld()
312
313
314
if Tool and script.ClassName == "Script" then
315
	--- Don't bother with local scripts
316
317
	script.Parent.AncestryChanged:connect(function()
318
		PerfectionWeld()
319
	end)
320
end
321
322
-- Created by Quenty (@Quenty, follow me on twitter).
323
324
end))
325
Script7.Name = "SwordScript"
326
Script7.Parent = Tool1
327
table.insert(cors,sandbox(Script7,function()
328
-------- OMG HAX
329
330
r = game:service("RunService")
331
332
333
local damage = 0
334
335
336
local slash_damage = 0
337
338
339
sword = script.Parent.Handle
340
Tool = script.Parent
341
342
343
local SlashSound = Instance.new("Sound")
344
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
345
SlashSound.Parent = sword
346
SlashSound.Volume = .7
347
348
349
local UnsheathSound = Instance.new("Sound")
350
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
351
UnsheathSound.Parent = sword
352
UnsheathSound.Volume = 1
353
354
355
function blow(hit)
356
	local humanoid = hit.Parent:findFirstChild("Humanoid of the Monster here ( make sure its humanoid is not named humanoid)")
357
	local vCharacter = Tool.Parent
358
	local vPlayer = game.Players:playerFromCharacter(vCharacter)
359
	local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
360
	if humanoid~=nil and humanoid ~= hum and hum ~= nil then
361
		-- final check, make sure sword is in-hand
362
363
		local right_arm = vCharacter:FindFirstChild("Right Arm")
364
		if (right_arm ~= nil) then
365
			local joint = right_arm:FindFirstChild("RightGrip")
366
			if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
367
				tagHumanoid(humanoid, vPlayer)
368
				humanoid:TakeDamage(damage)
369
				wait(1)
370
				untagHumanoid(humanoid)
371
			end
372
		end
373
374
375
	end
376
end
377
378
379
function tagHumanoid(humanoid, player)
380
	local creator_tag = Instance.new("ObjectValue")
381
	creator_tag.Value = player
382
	creator_tag.Name = "creator"
383
	creator_tag.Parent = humanoid
384
end
385
386
function untagHumanoid(humanoid)
387
	if humanoid ~= nil then
388
		local tag = humanoid:findFirstChild("creator")
389
		if tag ~= nil then
390
			tag.Parent = nil
391
		end
392
	end
393
end
394
395
396
function attack()
397
	damage = slash_damage
398
	SlashSound:play()
399
	local anim = Instance.new("StringValue")
400
	anim.Name = "toolanim"
401
	anim.Value = "Slash"
402
	anim.Parent = Tool
403
end
404
405
406
function swordUp()
407
	Tool.GripForward = Vector3.new(-1,0,0)
408
	Tool.GripRight = Vector3.new(0,1,0)
409
	Tool.GripUp = Vector3.new(0,0,1)
410
end
411
412
function swordOut()
413
	Tool.GripForward = Vector3.new(0,0,1)
414
	Tool.GripRight = Vector3.new(0,-1,0)
415
	Tool.GripUp = Vector3.new(-1,0,0)
416
end
417
418
419
420
Tool.Enabled = true
421
422
function onActivated()
423
424
	if not Tool.Enabled then
425
		return
426
	end
427
428
	Tool.Enabled = false
429
430
	local character = Tool.Parent;
431
	local humanoid = character.Humanoid
432
	if humanoid == nil then
433
		print("Humanoid not found")
434
		return 
435
	end
436
437
	
438
439
	attack()
440
441
	wait(.5)
442
443
	Tool.Enabled = true
444
end
445
446
447
function onEquipped()
448
	UnsheathSound:play()
449
end
450
451
452
script.Parent.Activated:connect(onActivated)
453
script.Parent.Equipped:connect(onEquipped)
454
455
456
connection = sword.Touched:connect(blow)
457
458
459
460
end))
461
Script8.Parent = mas
462
table.insert(cors,sandbox(Script8,function()
463
warn("created by: 5k5k5k5k5 left click to BAN!")
464
end))
465
for i,v in pairs(mas:GetChildren()) do
466
	v.Parent = workspace
467
	pcall(function() v:MakeJoints() end)
468
end
469
mas:Destroy()
470
for i,v in pairs(cors) do
471
	spawn(function()
472
		pcall(v)
473
	end)
474
end