· 6 years ago · Dec 19, 2019, 05:08 PM
1--https://github.com/Mokiros/roblox-FE-compatibility
2if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
3local Player,game,owner = owner,game
4local RealPlayer = Player
5do
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
87 local h,t
88 --Give the server mouse data every second frame, but only if the values changed
89 --If player is not moving their mouse, client won't fire events
90 local HB = game:GetService("RunService").Heartbeat
91 while true do
92 if h~=Mouse.Hit or t~=Mouse.Target then
93 h,t=Mouse.Hit,Mouse.Target
94 Event:FireServer({isMouse=true,Target=t,Hit=h})
95 end
96 --Wait 2 frames
97 for i=1,2 do
98 HB:Wait()
99 end
100 end]==],script)
101
102 ----Sandboxed game object that allows the usage of client-side methods and services
103 --Real game object
104 local RealGame = game
105
106 --Metatable for fake service
107 local FakeService_Metatable = {
108 __index = function(self,k)
109 local s = rawget(self,"_RealService")
110 if s then
111 return typeof(s[k])=="function"
112 and function(_,...)return s[k](s,...)end or s[k]
113 end
114 end,
115 __newindex = function(self,k,v)
116 local s = rawget(self,"_RealService")
117 if s then s[k]=v end
118 end
119 }
120 local function FakeService(t,RealService)
121 t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
122 return setmetatable(t,FakeService_Metatable)
123 end
124
125 --Fake game object
126 local FakeGame = {
127 GetService = function(self,s)
128 return rawget(self,s) or RealGame:GetService(s)
129 end,
130 Players = FakeService({
131 LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
132 },"Players"),
133 UserInputService = FakeService(UIS,"UserInputService"),
134 ContextActionService = FakeService(CAS,"ContextActionService"),
135 RunService = FakeService({
136 _btrs = {},
137 RenderStepped = RealGame:GetService("RunService").Heartbeat,
138 BindToRenderStep = function(self,name,_,fun)
139 self._btrs[name] = self.Heartbeat:Connect(fun)
140 end,
141 UnbindFromRenderStep = function(self,name)
142 self._btrs[name]:Disconnect()
143 end,
144 },"RunService")
145 }
146 rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
147 FakeGame.service = FakeGame.GetService
148 FakeService(FakeGame,game)
149 --Changing owner to fake player object to support owner:GetMouse()
150 game,owner = FakeGame,FakeGame.Players.LocalPlayer
151end
152
153function sandbox(var,func)
154 local env = getfenv(func)
155 local newenv = setmetatable({},{
156 __index = function(self,k)
157 if k=="script" then
158 return var
159 else
160 return env[k]
161 end
162 end,
163 })
164 setfenv(func,newenv)
165 return func
166end
167cors = {}
168mas = Instance.new("Model",game:GetService("Lighting"))
169Tool0 = Instance.new("Tool")
170Part1 = Instance.new("Part")
171SpecialMesh2 = Instance.new("SpecialMesh")
172Fire3 = Instance.new("Fire")
173Script4 = Instance.new("Script")
174Script5 = Instance.new("Script")
175LocalScript6 = Instance.new("LocalScript")
176LocalScript7 = Instance.new("LocalScript")
177Animation8 = Instance.new("Animation")
178BoolValue9 = Instance.new("BoolValue")
179Script10 = Instance.new("Script")
180Animation11 = Instance.new("Animation")
181Camera12 = Instance.new("Camera")
182Tool0.Name = "CircleBlade"
183Tool0.Parent = mas
184Tool0.TextureId = "http://ww.roblox.com/asset/?id=74322094"
185Tool0.Grip = CFrame.new(0, 0, 0, 0, -1.03063096e-11, -1, 0, 1, -1.03063096e-11, 1, 0, 0)
186Tool0.GripForward = Vector3.new(1, 1.03063096e-11, -0)
187Tool0.GripRight = Vector3.new(0, 0, 1)
188Tool0.GripUp = Vector3.new(-1.03063096e-11, 1, 0)
189Part1.Name = "Handle"
190Part1.Parent = Tool0
191Part1.CFrame = CFrame.new(52.0447426, 0.100080431, 97.0148849, -0.999992192, 4.68939543e-05, 1.3281403e-05, -6.123405e-06, -3.92836228e-06, -0.999992728, -5.40390611e-05, -0.999992311, 1.13901342e-05)
192Part1.Orientation = Vector3.new(89.7799988, 49.3800011, -122.68)
193Part1.Position = Vector3.new(52.0447426, 0.100080431, 97.0148849)
194Part1.Rotation = Vector3.new(90, 0, -180)
195Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
196Part1.Velocity = Vector3.new(-0.00149992807, 0.00018782774, -0.0013848017)
197Part1.Size = Vector3.new(3.38999939, 2.97000074, 0.200000003)
198Part1.BottomSurface = Enum.SurfaceType.Smooth
199Part1.BrickColor = BrickColor.new("Dark stone grey")
200Part1.RotVelocity = Vector3.new(-0.000780616945, 0.000357930578, 0.00883458368)
201Part1.TopSurface = Enum.SurfaceType.Smooth
202Part1.brickColor = BrickColor.new("Dark stone grey")
203Part1.FormFactor = Enum.FormFactor.Custom
204Part1.formFactor = Enum.FormFactor.Custom
205SpecialMesh2.Parent = Part1
206SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=74322089"
207SpecialMesh2.Scale = Vector3.new(2.5, 2.5, 2.5)
208SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=74322092"
209SpecialMesh2.MeshType = Enum.MeshType.FileMesh
210Fire3.Parent = Part1
211Fire3.Color = Color3.new(1, 0.678431, 0)
212Fire3.Enabled = false
213Fire3.Size = 30
214Fire3.Heat = 25
215Fire3.SecondaryColor = Color3.new(1, 0, 0)
216Fire3.size = 30
217Script4.Name = "Spread"
218Script4.Parent = Fire3
219table.insert(cors,sandbox(Script4,function()
220function Spread(part)
221 check = part:findFirstChild("Fire")
222 if check == nil then
223 script.Parent:Clone().Parent = part
224
225 elseif check ~= nil then
226 check.Size = check.Size + 1000000
227 check.Heat = check.Heat +1000000
228 end
229end
230
231
232script.Parent.Parent.Touched:connect(Spread)
233
234end))
235Script5.Parent = Part1
236table.insert(cors,sandbox(Script5,function()
237function onTouch(part)
238 local humanoid = part.Parent:FindFirstChild("Humanoid")
239 if (humanoid ~= nil) then -- if a humanoid exists, then
240 humanoid.Health = 0 -- damage the humanoid
241end
242end
243
244script.Parent.Touched:connect(onTouch)
245end))
246LocalScript6.Name = "Local Gui"
247LocalScript6.Parent = Tool0
248table.insert(cors,sandbox(LocalScript6,function()
249Tool = script.Parent
250
251local stillEquipped = true
252
253function onEquippedLocal(mouse)
254 stillEquipped = true
255 if mouse == nil then
256 print("Mouse not found")
257 return
258 end
259 while stillEquipped do
260 print("Setting Mouse to go")
261 mouse.Icon = "rbxasset://textures\\GunCursor.png"
262 while Tool.Enabled and stillEquipped do
263 wait(0.01)
264 end
265 print("Setting Mouse to wait")
266 mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
267 while not Tool.Enabled and stillEquipped do
268 wait(0.01)
269 end
270 end
271end
272
273function onUnequippedLocal()
274 stillEquipped = false
275end
276
277Tool.Equipped:connect(onEquippedLocal)
278Tool.Unequipped:connect(onUnequippedLocal)
279
280end))
281LocalScript7.Name = "ThrowScript"
282LocalScript7.Parent = Tool0
283table.insert(cors,sandbox(LocalScript7,function()
284local Tool = script.Parent
285local Blade = Tool.Handle
286
287local vCharacter
288local myTorso
289local myHumanoid
290local vPlayer
291
292Tool.Enabled = true
293
294local slashAnim
295
296local throwRing
297local terror
298
299local damage = 22
300
301local equipped = false
302
303local debris = game:GetService("Debris")
304
305function terrorize(key)
306 key = key:lower()
307 if vCharacter and myTorso and myHumanoid then
308 if key == "q" then
309 print("Throw ring")
310 throwRing = Tool:FindFirstChild("ThrowRing")
311 if throwRing and throwRing.Value == false then
312 print("Throwing")
313 throwRing.Value = true
314 end
315 elseif key == "r" then
316 terror = Tool:FindFirstChild("Terror")
317 throwRing = Tool:FindFirstChild("ThrowRing")
318 if terror and terror.Value == false then
319 terror.Value = true
320 end
321 end
322 end
323end
324
325function tagHumanoid(humanoid, player)
326 if humanoid ~= nil then
327 local creatorTag = Instance.new("ObjectValue")
328 creatorTag.Value = player
329 creatorTag.Name = "creator"
330 creatorTag.Parent = humanoid
331 debris:AddItem(creatorTag, 1.25)
332 end
333end
334
335function blow(hit)
336 if hit and hit.Parent and Blade.Transparency ~= 1.0 then
337 local humanoid = hit.Parent:FindFirstChild("Humanoid")
338 if humanoid and myHumanoid and humanoid ~= myHumanoid then
339 tagHumanoid(humanoid, vPlayer)
340 humanoid:TakeDamage(damage)
341 end
342 end
343end
344
345function onActivated()
346 if Tool.Enabled == false then
347 return
348 end
349
350 if myTorso == nil or myHumanoid == nil then
351 return
352 end
353
354 if throwRing and throwRing.Value == true then
355 return
356 end
357
358 Tool.Enabled = false
359 slashAnim = myHumanoid:LoadAnimation(Tool.SlashAnim)
360 if slashAnim then slashAnim:Play() end
361 wait(1.25)
362 Tool.Enabled = true
363end
364
365function onEquipped(mouse)
366 vCharacter = Tool.Parent
367 myTorso = vCharacter:FindFirstChild("Torso")
368 myHumanoid = vCharacter:FindFirstChild("Humanoid")
369 vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
370 if mouse then
371 mouse.KeyDown:connect(terrorize)
372 end
373
374 equipped = true
375
376 coroutine.resume(coroutine.create(function()
377 local theta = math.pi/6
378 while equipped do
379 Tool.GripForward = Vector3.new(math.cos(theta), math.sin(theta), 0)
380 Tool.GripUp = Vector3.new(-math.sin(theta), math.cos(theta), 0)
381 theta = theta + math.pi/6
382 wait()
383 end
384 Tool.Grip = CFrame.new(0, 0, 0, 0, 0, -1, 0, 1, 0, 1, -0, 0)
385 end))
386end
387
388function onUnequipped()
389 if slashAnim then slashAnim:Stop() end
390 equipped = false
391end
392
393Tool.Activated:connect(onActivated)
394Tool.Equipped:connect(onEquipped)
395Tool.Unequipped:connect(onUnequipped)
396
397Blade.Touched:connect(blow)
398
399while Tool:FindFirstChild("ThrowRing") == nil do
400 wait()
401end
402
403throwRing = Tool.ThrowRing
404
405
406
407
408
409
410end))
411Animation8.Name = "SlashAnimv2"
412Animation8.Parent = Tool0
413Animation8.AnimationId = "http://www.roblox.com/Asset?ID=63234156"
414BoolValue9.Name = "ThrowRing"
415BoolValue9.Parent = Tool0
416Script10.Name = "BladeScript"
417Script10.Parent = Tool0
418table.insert(cors,sandbox(Script10,function()
419local Tool = script.Parent
420local Blade = Tool.Handle
421
422local vCharacter
423local myTorso
424local myHumanoid
425local vPlayer
426
427local terror
428local throwRing
429
430local cloneId = 68452456
431
432local maxDistance = 45.0
433
434local awayFromCharacter = false
435
436local clone = game:GetService("InsertService"):LoadAsset(cloneId):GetChildren()[1]
437local currentClone
438
439local debris = game:GetService("Debris")
440
441while Tool:FindFirstChild("ThrowRing") == nil do
442 wait()
443end
444
445local damage = 16
446
447function tagHumanoid(humanoid, player)
448 if humanoid ~= nil then
449 local creatorTag = Instance.new("ObjectValue")
450 creatorTag.Value = player
451 creatorTag.Name = "creator"
452 creatorTag.Parent = humanoid
453 debris:AddItem(creatorTag, 1.25)
454 end
455end
456
457function blow(hit)
458 if hit and hit.Parent then
459 local humanoid = hit.Parent:FindFirstChild("Humanoid")
460 if humanoid and myHumanoid and humanoid ~= myHumanoid then
461 tagHumanoid(humanoid, vPlayer)
462 humanoid:TakeDamage(damage)
463 awayFromCharacter = false
464 end
465 end
466end
467
468function returnToCharacter(cloneBlade)
469 if cloneBlade and myTorso then
470 local distance = (cloneBlade.Position - myTorso.Position).magnitude
471 local lookAt = (myTorso.Position - cloneBlade.Position).unit
472 while distance > 4.0 and cloneBlade do
473 cloneBlade.Velocity = lookAt * 45.0
474 if cloneBlade then
475 lookAt = (myTorso.Position - cloneBlade.Position).unit
476 distance = (myTorso.Position - cloneBlade.Position).magnitude
477 end
478 wait()
479 end
480 if cloneBlade then
481 cloneBlade:Remove()
482 cloneBlade = nil
483 end
484 wait(0.25)
485 end
486end
487
488function throw(cloneBlade, direction)
489 local spawnPos = Blade.Position + direction * 4.0
490 cloneBlade.CFrame = CFrame.new(spawnPos, spawnPos + direction) * CFrame.Angles(math.pi/2, 0, 0)
491 cloneBlade.CanCollide = false
492
493 cloneBlade.Velocity = direction * 45.0
494 cloneBlade.RotVelocity = Vector3.new(0, 40, 0)
495
496 local floatForce = Instance.new("BodyForce")
497 floatForce.force = Vector3.new(0, cloneBlade:GetMass() * 196.1, 0)
498 floatForce.Parent = cloneBlade
499
500 cloneBlade.Parent = game.Workspace
501
502 cloneBlade.Touched:connect(function(hit) blow(hit) end)
503
504 awayFromCharacter = true
505
506 local distance = (cloneBlade.Position - spawnPos).magnitude
507 while awayFromCharacter and distance < maxDistance do
508 distance = (cloneBlade.Position - spawnPos).magnitude
509 wait(0.25)
510 end
511 awayFromCharacter = false
512 returnToCharacter(cloneBlade)
513end
514
515throwRing = Tool.ThrowRing
516throwRing.Changed:connect(function()
517 if throwRing and throwRing.Value == true and myHumanoid then
518 Blade.Transparency = 1.0
519 local cloneBlade = Blade:Clone()
520 cloneBlade.Transparency = 0.0
521 local target = myHumanoid.TargetPoint
522 local direction = (target - Blade.Position).unit
523 coroutine.resume(coroutine.create(function() throw(cloneBlade, direction) end))
524 Tool.Enabled = false
525 wait(5.0)
526 Tool.Enabled = true
527 Blade.Transparency = 0.0
528 throwRing.Value = false
529 end
530end)
531
532function onEquipped()
533 vCharacter = Tool.Parent
534 myTorso = vCharacter:FindFirstChild("Torso")
535 myHumanoid = vCharacter:FindFirstChild("Humanoid")
536 vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
537end
538
539Tool.Equipped:connect(onEquipped)
540
541end))
542Animation11.Name = "SlashAnim"
543Animation11.Parent = Tool0
544Animation11.AnimationId = "http://www.roblox.com/Asset?ID=74322484"
545Camera12.Name = "ThumbnailCamera"
546Camera12.Parent = Tool0
547Camera12.CFrame = CFrame.new(47.2182541, 0.242027581, -30.0140095, -0.00702209957, 0.233444467, 0.972344756, -0, 0.972368717, -0.233450219, -0.999975383, -0.00163931074, -0.00682806969)
548Camera12.CoordinateFrame = CFrame.new(47.2182541, 0.242027581, -30.0140095, -0.00702209957, 0.233444467, 0.972344756, -0, 0.972368717, -0.233450219, -0.999975383, -0.00163931074, -0.00682806969)
549Camera12.Focus = CFrame.new(43.9916649, 1.01669931, -29.9913521, 1, 0, 0, 0, 1, 0, 0, 0, 1)
550Camera12.focus = CFrame.new(43.9916649, 1.01669931, -29.9913521, 1, 0, 0, 0, 1, 0, 0, 0, 1)
551for i,v in pairs(mas:GetChildren()) do
552 v.Parent = game:GetService("Players").LocalPlayer.Backpack
553 pcall(function() v:MakeJoints() end)
554end
555mas:Destroy()
556for i,v in pairs(cors) do
557 spawn(function()
558 pcall(v)
559 end)
560end