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