View difference between Paste ID: ukYr1kTP and Jmzm5Qzi
SHOW: | | - or go back to the newest paste.
1
-- This script has been converted to FE by iPxter
2
3
4
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
5
local Player,Mouse,mouse,UserInputService,ContextActionService = owner
6
do
7-
local player = game:service("Players").LocalPlayer
7+
	print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
8-
local mouse = player:GetMouse() 
8+
	script.Parent = Player.Character
9
10
	--RemoteEvent for communicating
11
	local Event = Instance.new("RemoteEvent")
12
	Event.Name = "UserInput_Event"
13
14
	--Fake event to make stuff like Mouse.KeyDown work
15
	local function fakeEvent()
16
		local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
17
		t.connect = t.Connect
18
		return t
19
	end
20
21
	--Creating fake input objects with fake variables
22
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
23
	local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
24
	local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
25
		CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
26
	end}
27
	--Merged 2 functions into one by checking amount of arguments
28
	CAS.UnbindAction = CAS.BindAction
29
30
	--This function will trigger the events that have been :Connect()'ed
31
	local function te(self,ev,...)
32
		local t = m[ev]
33
		if t and t._fakeEvent and t.Function then
34
			t.Function(...)
35
		end
36
	end
37
	m.TrigEvent = te
38
	UIS.TrigEvent = te
39
40
	Event.OnServerEvent:Connect(function(plr,io)
41
	    if plr~=Player then return end
42
		if io.isMouse then
43
			m.Target = io.Target
44
			m.Hit = io.Hit
45
		else
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
			for _,t in pairs(CAS.Actions) do
51
				for _,k in pairs(t.Keys) do
52
					if k==io.KeyCode then
53
						t.Function(t.Name,io.UserInputState,io)
54
					end
55
				end
56
			end
57
			m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
58
			UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
59
	    end
60
	end)
61
	Event.Parent = NLS([==[
62
	local Player = game:GetService("Players").LocalPlayer
63
	local Event = script:WaitForChild("UserInput_Event")
64
65
	local UIS = game:GetService("UserInputService")
66
	local input = function(io,a)
67
		if a then return end
68
		--Since InputObject is a client-side instance, we create and pass table instead
69
		Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
70
	end
71
	UIS.InputBegan:Connect(input)
72
	UIS.InputEnded:Connect(input)
73
74
	local Mouse = Player:GetMouse()
75
	local h,t
76
	--Give the server mouse data 30 times every second, but only if the values changed
77
	--If player is not moving their mouse, client won't fire events
78
	while wait(1/30) do
79
		if h~=Mouse.Hit or t~=Mouse.Target then
80
			h,t=Mouse.Hit,Mouse.Target
81
			Event:FireServer({isMouse=true,Target=t,Hit=h})
82
		end
83
	end]==],Player.Character)
84
	Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
85
end
86
87
88
for i, v in pairs(game.Players.LocalPlayer.Backpack:children()) do 
89
        if v.className == "HopperBin" and v.Name == "PPATTA's Trap Script" then 
90
                v:Destroy() 
91
        end 
92
end 
93
94
local player = owner
95
local char = player.Character 
96
local Torsoz = char:findFirstChild("Torso") 
97
local RA = char:findFirstChild("Right Arm") 
98
local LA = char:findFirstChild("Left Arm") 
99
local RL = char:findFirstChild("Right Leg") 
100
local LL = char:findFirstChild("Left Leg") 
101
local H = char:findFirstChild("Head") 
102
local RS = Torsoz:findFirstChild("Right Shoulder") 
103
local LS = Torsoz:findFirstChild("Left Shoulder") 
104
local RH = Torsoz:findFirstChild("Right Hip") 
105
local LH = Torsoz:findFirstChild("Left Hip") 
106
local N = Torsoz:findFirstChild("Neck") 
107
local NV = Vector3.new() 
108
local Main 
109
local Traps = {} 
110
local Projectiles = {} 
111
local Bolts = {} 
112
113
local bin = Instance.new("HopperBin") 
114
bin.Name = "PPATTA's Trap Script" 
115
bin.Parent = player.Backpack 
116
117
local P = Instance.new("Part") 
118
P.Anchored = false 
119
P.CanCollide = false 
120
P.Name = "Part" 
121
P.formFactor = "Custom" 
122
P.Size = Vector3.new(0.2,0.2,0.2) 
123
P.BrickColor = BrickColor.new("Black") 
124
P.Locked = true 
125
P.TopSurface = 10 
126
P.BottomSurface = 10 
127
P.FrontSurface = 10 
128
P.BackSurface = 10 
129
P.LeftSurface = 10 
130
P.RightSurface = 10 
131
132
local AnimJoints = {} 
133
134
function GetWeld(weld) 
135
        local obj 
136
        for i, v in pairs(AnimJoints) do 
137
                if v[1] == weld then 
138
                        obj = v 
139
                        break 
140
                end 
141
        end 
142
        if not obj then 
143
                obj = {weld,NV} 
144
                table.insert(AnimJoints,obj) 
145
        end 
146
        return weld.C0.p, obj[2] 
147
end 
148
149
function SetWeld(weld, i, loops, origpos,origangle, nextpos,nextangle,smooth) 
150
        smooth = smooth or 1 
151
        local obj 
152
        for i, v in pairs(AnimJoints) do 
153
                if v[1] == weld then 
154
                        obj = v 
155
                        break 
156
                end 
157
        end 
158
        if not obj then 
159
                obj = {weld,NV} 
160
                table.insert(AnimJoints,obj) 
161
        end 
162
        
163
        local perc = (smooth == 1 and math.sin((math.pi/2)/loops*i)) or i/loops 
164
        
165
        local tox,toy,toz = 0,0,0 
166
        tox = math.abs(origangle.x - nextangle.x) *perc 
167
        toy = math.abs(origangle.y - nextangle.y) *perc 
168
        toz = math.abs(origangle.z - nextangle.z) *perc 
169
        tox = (origangle.x > nextangle.x and -tox) or tox 
170
        toy = (origangle.y > nextangle.y and -toy) or toy 
171
        toz = (origangle.z > nextangle.z and -toz) or toz 
172
        
173
        local tox2,toy2,toz2 = 0,0,0 
174
        tox2 = math.abs(origpos.x - nextpos.x) *perc 
175
        toy2 = math.abs(origpos.y - nextpos.y) *perc 
176
        toz2 = math.abs(origpos.z - nextpos.z) *perc 
177
        tox2 = (origpos.x > nextpos.x and -tox2) or tox2 
178
        toy2 = (origpos.y > nextpos.y and -toy2) or toy2 
179
        toz2 = (origpos.z > nextpos.z and -toz2) or toz2 
180
        
181
        obj[2] = Vector3.new(origangle.x + tox, origangle.y + toy, origangle.z + toz) 
182
        weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz) 
183
end 
184
185
function RAY(pos, dir, collidedlist, startpos, endpos, distleft) 
186
        collidedlist = collidedlist or {char} 
187
        startpos = startpos or pos 
188
        distleft = distleft or dir.unit * dir.magnitude 
189
        endpos = endpos or pos + distleft 
190
        local ray = Ray.new(pos, distleft) 
191
        local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist) 
192
        if hitz ~= nil and not hitz.Parent:findFirstChild("Humanoid") then 
193
                if hitz.CanCollide == false then 
194
                        table.insert(collidedlist, hitz) 
195
                        local newpos = enz 
196
                        local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude) 
197
                        if newdistleft ~= NV then 
198
                                return RAY(newpos-(dir*0.01), dir, collidedlist, startpos, endpos, newdistleft+(dir*0.01)) 
199
                        end 
200
                end 
201
        end 
202
        return hitz, enz, ray 
203
end 
204
205
function FindSurface(part, position) 
206
        local obj = part.CFrame:pointToObjectSpace(position) 
207
        local siz = part.Size/2 
208
        for i,v in pairs(Enum.NormalId:GetEnumItems()) do 
209
                local vec = Vector3.FromNormalId(v) 
210
                local wvec = part.CFrame:vectorToWorldSpace(vec) 
211
                local vz = (obj)/(siz*vec) 
212
                if (math.abs(vz.X-1) < 0.01 or math.abs(vz.Y-1) < 0.01 or math.abs(vz.Z-1) < 0.01) then
213
                        return wvec,vec 
214
                end 
215
        end 
216
        if part.className == "WedgePart" then 
217
                local pos = (part.CFrame * CFrame.new(0,part.Size.y/2,part.Size.z/2)).p 
218
                local apos = (part.CFrame * CFrame.Angles(-math.atan2(part.CFrame:pointToObjectSpace(pos).y,part.CFrame:pointToObjectSpace(pos).z),0,0) * CFrame.new(0,1,0)).p 
219
                local wvec,vec = (apos - part.Position).unit, part.CFrame:pointToObjectSpace(apos) 
220
                return wvec,vec 
221
        elseif part.className == "Part" and (part.Shape == Enum.PartType.Ball or part.Shape == Enum.PartType.Cylinder) then 
222
                return (position - part.Position).unit, part.CFrame:vectorToObjectSpace((position - part.Position).unit) 
223
        end 
224
end 
225
226
function CreateTrap(target,pos) 
227
        local m = Instance.new("Model", char) 
228
        m.Name = "Trap" 
229
230
        local cframe = CFrame.new() 
231
        local anchor = true 
232
233
        if not target:IsA("Terrain") then 
234
                local wvec,vec = FindSurface(target,pos) 
235
                cframe = CFrame.new(NV,wvec) * CFrame.Angles(-math.pi/2,0,0) 
236
                anchor = target.Anchored 
237
        end 
238
239
        local c = P:Clone() 
240
        c.Parent = m 
241
        c.Anchored = anchor 
242
        c.CanCollide = true 
243
        c.CFrame = (cframe +pos) * CFrame.Angles(0,math.rad(math.random(1,360)),0) 
244
        c.BrickColor = BrickColor.new("Dark stone grey") 
245
        local light = Instance.new("PointLight", c) 
246
        light.Brightness = 2 
247
        light.Range = 7 
248
        light.Color = Color3.new(1,0.8,0.1) 
249
        local mesh = Instance.new("CylinderMesh",c) 
250
        mesh.Scale = Vector3.new(0.2,0.4,0.2) *5 
251
        if not anchor then 
252
                local newpos = target.CFrame:toObjectSpace(c.CFrame) 
253
                local w = Instance.new("Weld",c) 
254
                w.Part0 = target 
255
                w.Part1 = c 
256
                w.C0 = newpos
257
        end 
258
259
        local tabl = {} 
260
        for i = 1, 3 do 
261
                local p = P:Clone() 
262
                p.Parent = m 
263
                p.Anchored = anchor 
264
                p.CFrame = c.CFrame * CFrame.Angles(0,math.pi*2/3*i,0) * CFrame.new(0,0.04,-0.12) * CFrame.Angles(-math.pi/2 +0.05,0,0) * CFrame.new(0,0.55,0) 
265
                local mesh = Instance.new("SpecialMesh",p) 
266
                mesh.MeshType = "Wedge" 
267
                mesh.Scale = Vector3.new(0.15,1.2,0.16) *5 
268
                if not anchor then 
269
                        local w = Instance.new("Weld",p) 
270
                        w.Part0 = c 
271
                        w.Part1 = p 
272
                        w.C0 = CFrame.Angles(0,math.pi*2/3*i,0) * CFrame.new(0,0.04,-0.12) * CFrame.Angles(-math.pi/2 +0.05,0,0) * CFrame.new(0,0.55,0) 
273
                end 
274
275
                for j = -1,1,2 do 
276
                        local p = P:Clone() 
277
                        p.Parent = m 
278
                        p.Anchored = anchor 
279
                        p.Transparency = 0.6 
280
                        p.BrickColor = BrickColor.new("Bright yellow") 
281
                        p.CFrame = c.CFrame * CFrame.new(0,0.2,0) * CFrame.Angles(0,math.pi*2/3*i,0) * CFrame.new(0.32*j,0,-0.55) * CFrame.Angles(0.06,0,-math.pi/2*j) 
282
                        local mesh = Instance.new("SpecialMesh",p) 
283
                        mesh.MeshType = "Wedge" 
284
                        mesh.Scale = Vector3.new(0.03,0.6,1.1) *5 
285
                        if not anchor then 
286
                                local w = Instance.new("Weld",p) 
287
                                w.Part0 = c 
288
                                w.Part1 = p 
289
                                w.C0 = CFrame.new(0,0.2,0) * CFrame.Angles(0,math.pi*2/3*i,0) * CFrame.new(0.32*j,0,-0.55) * CFrame.Angles(0.06,0,-math.pi/2*j) 
290
                        end 
291
                        table.insert(tabl,p) 
292
                end 
293
        end 
294
295
        table.insert(Traps,{m,c,tabl,0,light}) 
296
end 
297
298
function Build() 
299
        for i, v in pairs(char:children()) do 
300
                if v.className == "Model" and (v.Name == "" or v.Name == "Trap" or v.Name == "TrapProjectile") then 
301
                        v:Destroy() 
302
                end 
303
        end 
304
        local mdl = Instance.new("Model", char) 
305
        mdl.Name = "" 
306
307
end 
308
Build() 
309
310
function Throw(aim) 
311
        local mdl = Instance.new("Model",char) 
312
        mdl.Name = "TrapProjectile" 
313
        local p = P:Clone() 
314
        p.Parent = mdl 
315
        p.Anchored = true 
316
        p.Size = Vector3.new(0.5,0.5,1.5) 
317
        p.CFrame = CFrame.new(Torsoz.Position,Torsoz.Position+aim) 
318
        table.insert(Projectiles,{mdl,p,aim,0.05}) 
319
end 
320
321
function JumbleBolt(bolt) 
322
        local lastpos = bolt[2][3] 
323
        for i, v in pairs(bolt) do 
324
                if i == 1 then 
325
                        bolt[1] = bolt[1] - 1 
326
                else 
327
                        local point = v[4] * CFrame.new(math.random(-100,100)*v[5]/200,math.random(-100,100)*v[5]/200,0) 
328
                        v[1].CFrame = CFrame.new((lastpos+point.p)/2,point.p) 
329
                        v[2].Scale = Vector3.new(0.1,0.1,(lastpos-point.p).magnitude) *5 
330
                        lastpos = point.p 
331
                end 
332
        end 
333
end 
334
335
function Bolt(par,start,endpos,jumble) 
336
        jumble = jumble or 8 
337
        local dist = (start - endpos).magnitude 
338
        if dist < 200 then 
339
                local tab = {jumble} 
340
                local dir = (endpos - start).unit 
341
                local jump = dist/math.floor(dist) 
342
                local lastpos = start 
343
                local lastraw 
344
                for i = 1, math.floor(dist) do 
345
                        local rawpoint = CFrame.new(start,endpos) + dir*jump*i 
346
                        local point = rawpoint 
347
                        if i ~= math.floor(dist) then 
348
                                point = point * CFrame.new(math.random(-100,100)*jump/200,math.random(-100,100)*jump/200,0) 
349
                        end 
350
                        local p = P:Clone() 
351
                        p.Parent = par 
352
                        p.Anchored = true 
353
                        p.BrickColor = BrickColor.new("Royal purple") 
354
                        p.CFrame = CFrame.new((lastpos+point.p)/2,point.p) 
355
                        local mesh = Instance.new("BlockMesh",p) 
356
                        mesh.Scale = Vector3.new(0.1,0.1,(lastpos-point.p).magnitude) *5 
357
                        game:GetService("Debris"):AddItem(p,5) 
358
                        table.insert(tab,{p,mesh,start,rawpoint,jump}) 
359
                        lastpos = point.p 
360
                        lastraw = rawpoint 
361
                end 
362
                table.insert(Bolts,tab) 
363
        end 
364
end 
365
366
function Explode(pos,bolts) 
367
        local mdl = Instance.new("Model",char) 
368
        mdl.Name = "Explosion" 
369
        local p = P:Clone() 
370
        p.Parent = mdl 
371
        p.Anchored = true 
372
        p.CanCollide = false 
373
        p.CFrame = CFrame.new(pos) 
374
        local l = Instance.new("PointLight",p) 
375
        l.Color = Color3.new(0.5,0.1,1) 
376
        l.Range = 10 
377
        l.Brightness = 2 
378
        game:GetService("Debris"):AddItem(mdl,0.7) 
379
        for i, v in pairs(game:GetService("Players"):GetChildren()) do 
380
                if v.Character ~= nil then 
381
                        if v.Character:findFirstChild("Torso") and v.Character:findFirstChild("Humanoid") then 
382
                                if (v.Character.Torso.Position - pos).magnitude < 6.5 then 
383
                                        v.Character.Humanoid:TakeDamage(math.random(30,45)) 
384
                                end 
385
                        end 
386
                end 
387
        end 
388
        for i = 1, bolts do 
389
                local dist = math.random(38,64) /10 
390
                local dir = Vector3.new(math.random(-50,50),math.random(-50,50),math.random(-50,50)).unit 
391
                Bolt(mdl,pos,pos+dir*dist) 
392
        end 
393
end 
394
395
function Detonate() 
396
        for i, v in pairs(Traps) do 
397
                Explode(v[2].Position,10) 
398
                v[1]:Destroy() 
399
                Traps[i] = nil 
400
        end 
401
end 
402
403
function B1D(mouse) 
404
        --[[if mouse.Target and #Traps < 6 then 
405
                CreateTrap(mouse.Hit.p,mouse.Target) 
406
        end ]]
407
        if #Traps + #Projectiles < 6 then 
408
                Throw((mouse.Hit.p - Torsoz.Position).unit) 
409
        end 
410
        --Bolt(char,Torsoz.Position,mouse.Hit.p) 
411
        --Explode(mouse.Hit.p,10) 
412
end 
413
414
function KD(key, mouse) 
415
        if key == "e" then 
416
                Detonate() 
417
        --[[elseif key == "r" then 
418
                for i, v in pairs(Traps) do 
419
                        v[1]:Destroy() 
420
                        Traps[i] = nil 
421
                end ]]
422
        end 
423
end 
424
425
function Equip() 
426
end 
427
428
function Unequip() 
429
end 
430
431
bin.Selected:connect(function(mouse) 
432
        mouse.Icon = "rbxasset://textures\\GunCursor.png" 
433
        mouse.Button1Down:connect(function() B1D(mouse) end) 
434
        mouse.KeyDown:connect(function(key) KD(key, mouse) end) 
435
end) 
436
437
bin.Deselected:connect(function() 
438
end) 
439
440
local jumpcount = 0 
441
game:GetService("RunService").Stepped:connect(function() 
442
        jumpcount = (jumpcount%2) + 1 
443
        for i, trap in pairs(Traps) do 
444
                trap[4] = (trap[4] + 1) %2 
445
                if trap[4] == 0 then 
446
                        local randum = math.random() 
447
                        local zaptrans = 0.3 + 0.45*randum 
448
                        trap[5].Brightness = 0.8 + 2.8*randum --math.random(-65,60)/100 
449
                        for j, v in pairs(trap[3]) do 
450
                                v.Transparency = zaptrans 
451
                        end 
452
                end 
453
        end 
454
455
        for i, proj in pairs(Projectiles) do 
456
                local spd = (proj[3]*3) + Vector3.new(0,proj[4],0) 
457
                local hitz,enz = RAY(proj[2].Position,spd) 
458
                if hitz then 
459
                        proj[1]:Destroy() 
460
                        CreateTrap(hitz,enz) 
461
                        table.remove(Projectiles,i) 
462
                else 
463
                        proj[2].CFrame = CFrame.new(NV,spd) + proj[2].Position + spd 
464
                        proj[4] = proj[4] - 0.05 
465
                end 
466
        end 
467
468
        if jumpcount == 1 then 
469
                for i, bolt in pairs(Bolts) do 
470
                        JumbleBolt(bolt) 
471
                        if bolt[1] <= 0 then 
472
                                for j, v in pairs(bolt) do 
473
                                        if j ~= 1 then 
474
                                                v[1]:Destroy() 
475
                                        end 
476
                                end 
477
                                table.remove(Bolts,i) 
478
                        end 
479
                end 
480
        end 
481
end)