Advertisement
Zach_rookie_editor3

Linked Sword

Dec 10th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.50 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient()then error("Please run as a server script. Use h/ instead of hl/.")end;print("FE Compatibility: by WaverlyCole");InternalData = {}
  2. do
  3. script.Parent = owner.Character
  4. local Event = Instance.new("RemoteEvent");Event.Name = "UserInput"
  5. local function NewFakeEvent()
  6. local Bind = Instance.new("BindableEvent")
  7. local Fake;Fake = {Connections = {},
  8. fakeEvent=true;
  9. Connect=function(self,Func)
  10. Bind.Event:connect(Func)
  11. self.Connections[Bind] = true
  12. return setmetatable({Connected = true},{
  13. __index = function (self,Index)
  14. if Index:lower() == "disconnect" then
  15. return function() Fake.Connections[Bind] = false;self.Connected = false end
  16. end
  17. return Fake[Index]
  18. end;
  19. __tostring = function() return "Connection" end;
  20. })
  21. end}
  22. Fake.connect = Fake.Connect;return Fake;
  23. end
  24. local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
  25. local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
  26. local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
  27. self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
  28. end};ContextActionService.UnBindAction = ContextActionService.BindAction
  29. local function TriggerEvent(self,Event,...)
  30. local Trigger = Mouse[Event]
  31. if Trigger and Trigger.fakeEvent and Trigger.Connections then
  32. for Connection,Active in pairs(Trigger.Connections) do if Active then Connection:Fire(...) end end
  33. end
  34. end
  35. Mouse.TrigEvent = TriggerEvent;UserInputService.TrigEvent = TriggerEvent
  36. Event.OnServerEvent:Connect(function(FiredBy,Input)
  37. if FiredBy.Name ~= owner.Name then return end
  38. if Input.MouseEvent then
  39. Mouse.Target = Input.Target;Mouse.Hit = Input.Hit
  40. else
  41. local Begin = Input.UserInputState == Enum.UserInputState.Begin
  42. if Input.UserInputType == Enum.UserInputType.MouseButton1 then return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up") end
  43. for _,Action in pairs(ContextActionService.Actions) do
  44. for _,Key in pairs(Action.Keys) do if Key==Input.KeyCode then Action.Function(Action.Name,Input.UserInputState,Input) end end
  45. end
  46. Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
  47. UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
  48. end
  49. end)
  50. InternalData["Mouse"] = Mouse;InternalData["ContextActionService"] = ContextActionService;InternalData["UserInputService"] = UserInputService
  51. Event.Parent = NLS([[
  52. local Player = owner;local Event = script:WaitForChild("UserInput");local UserInputService = game:GetService("UserInputService");local Mouse = Player:GetMouse()
  53. local Input = function(Input,gameProcessedEvent)
  54. if gameProcessedEvent then return end
  55. Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
  56. end
  57. UserInputService.InputBegan:Connect(Input);UserInputService.InputEnded:Connect(Input)
  58. local Hit,Target
  59. while wait(1/30) do
  60. if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
  61. Hit,Target = Mouse.Hit,Mouse.Target;Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
  62. end
  63. end
  64. ]],owner.Character)
  65. end
  66. RealGame = game;game = setmetatable({},{
  67. __index = function (self,Index)
  68. local Sandbox = function (Thing)
  69. if Thing:IsA("Player") then
  70. local RealPlayer = Thing
  71. return setmetatable({},{
  72. __index = function (self,Index)
  73. local Type = type(RealPlayer[Index])
  74. if Type == "function" then
  75. if Index:lower() == "getmouse" or Index:lower() == "mouse" then
  76. return function (self)return InternalData["Mouse"] end
  77. end
  78. return function (self,...)return RealPlayer[Index](RealPlayer,...) end
  79. end
  80. return RealPlayer[Index]
  81. end;
  82. __tostring = function(self) return RealPlayer.Name end
  83. })
  84. end
  85. end
  86. if RealGame[Index] then
  87. local Type = type(RealGame[Index])
  88. if Type == "function" then
  89. if Index:lower() == "getservice" or Index:lower() == "service" then
  90. return function (self,Service)
  91. local FakeServices = {
  92. ["players"] = function()
  93. return setmetatable({},{
  94. __index = function (self2,Index2)
  95. local RealService = RealGame:GetService(Service)
  96. local Type2 = type(Index2)
  97. if Type2 == "function" then
  98. return function (self,...) return RealService[Index2](RealService,...)end
  99. else
  100. if Index2:lower() == "localplayer" then return Sandbox(owner) end
  101. return RealService[Index2]
  102. end
  103. end;
  104. __tostring = function(self) return RealGame:GetService(Service).Name end
  105. })
  106. end;
  107. ["contextactionservice"] = function() return InternalData["ContextActionService"] end;
  108. ["userinputservice"] = function() return InternalData["UserInputService"] end;
  109. ["runservice"] = function()
  110. return setmetatable({},{
  111. __index = function(self2,Index2)
  112. local RealService = RealGame:GetService(Service)
  113. local Type2 = type(Index2)
  114. if Type2 == "function" then
  115. return function (self,...) return RealService[Index2](RealService,...) end
  116. else
  117. local RunServices = {
  118. ["bindtorenderstep"] = function() return function (self,Name,Priority,Function) return RealGame:GetService("RunService").Stepped:Connect(Function) end end;
  119. ["renderstepped"] = function() return RealService["Stepped"] end
  120. }
  121. if RunServices[Index2:lower()] then return RunServices[Index2:lower()]() end
  122. return RealService[Index2]
  123. end
  124. end
  125. })
  126. end
  127. }
  128. if FakeServices[Service:lower()] then return FakeServices[Service:lower()]() end
  129. return RealGame:GetService(Service)
  130. end
  131. end
  132. return function (self,...) return RealGame[Index](RealGame,...) end
  133. else
  134. if game:GetService(Index) then return game:GetService(Index) end
  135. return RealGame[Index]
  136. end
  137. end
  138. return nil
  139. end
  140. });Game = game;owner = game:GetService("Players").LocalPlayer;script = Instance.new("Script");print("Complete! Running...")
  141. print(" made by zachrogamehard133447")
  142.  
  143. local runDummyScript = function(f,scri)
  144. local oldenv = getfenv(f)
  145. local newenv = setmetatable({}, {
  146. __index = function(_, k)
  147. if k:lower() == 'script' then
  148. return scri
  149. else
  150. return oldenv[k]
  151. end
  152. end
  153. })
  154. setfenv(f, newenv)
  155. ypcall(function() f() end)
  156. end
  157. cors = {}
  158. mas = Instance.new("Model",game:GetService("Lighting"))
  159. mas.Name = "CompiledModel"
  160. o1 = Instance.new("Tool")
  161. o2 = Instance.new("Part")
  162. o3 = Instance.new("Sound")
  163. o4 = Instance.new("Sound")
  164. o5 = Instance.new("Sound")
  165. o6 = Instance.new("SpecialMesh")
  166. o8 = Instance.new("Script")
  167. o9 = Instance.new("LocalScript")
  168. o10 = Instance.new("StringValue")
  169. o11 = Instance.new("StringValue")
  170. o12 = Instance.new("StringValue")
  171. o13 = Instance.new("StringValue")
  172. o1.Name = "Sword"
  173. o1.Parent = mas
  174. o1.TextureId = "http://www.roblox.com/asset/?id=124987047"
  175. o1.GripForward = Vector3.new(-1, -0, -0)
  176. o1.GripPos = Vector3.new(0, 0, -1.5)
  177. o1.GripRight = Vector3.new(0, 1, 0)
  178. o1.GripUp = Vector3.new(0, 0, 1)
  179. o2.Name = "Handle"
  180. o2.Parent = o1
  181. o2.BrickColor = BrickColor.new("Dark stone grey")
  182. o2.Reflectance = 0.40000000596046
  183. o2.Position = Vector3.new(-467.235016, 13.2509699, -419.589142)
  184. o2.Rotation = Vector3.new(-180, 5.09000015, -90)
  185. o2.CanCollide = false
  186. o2.Locked = true
  187. o2.FormFactor = Enum.FormFactor.Custom
  188. o2.Size = Vector3.new(1, 0.800000012, 4)
  189. o2.CFrame = CFrame.new(-467.235016, 13.2509699, -419.589142, -8.74267062e-06, 0.996058226, 0.0887008458, 1, 7.95604228e-06, 9.22190611e-06, 8.47984938e-06, 0.0887008458, -0.996058226)
  190. o2.BottomSurface = Enum.SurfaceType.Smooth
  191. o2.TopSurface = Enum.SurfaceType.Smooth
  192. o2.Color = Color3.new(0.388235, 0.372549, 0.384314)
  193. o2.Position = Vector3.new(-467.235016, 13.2509699, -419.589142)
  194. o3.Name = "Lunge"
  195. o3.Parent = o2
  196. o3.SoundId = "http://www.roblox.com/asset/?id=12222208"
  197. o3.Volume = 0.60000002384186
  198. o4.Name = "Slash"
  199. o4.Parent = o2
  200. o4.SoundId = "http://www.roblox.com/asset/?id=12222216"
  201. o4.Volume = 0.69999998807907
  202. o5.Name = "Unsheath"
  203. o5.Parent = o2
  204. o5.SoundId = "http://www.roblox.com/asset/?id=12222225"
  205. o5.Volume = 1
  206. o6.Parent = o2
  207. o6.MeshId = "http://www.roblox.com/asset/?id=12221720"
  208. o6.TextureId = "http://www.roblox.com/asset/?id=12224218"
  209. o6.MeshType = Enum.MeshType.FileMesh
  210. o8.Name = "SwordScript"
  211. o8.Parent = o1
  212. table.insert(cors,coroutine.create(function()
  213. wait()
  214. runDummyScript(function()
  215. --Rescripted by Luckymaxer
  216.  
  217. Tool = script.Parent
  218. Handle = Tool:WaitForChild("Handle")
  219. Mesh = Handle:WaitForChild("Mesh")
  220.  
  221. Players = game:GetService("Players")
  222. Debris = game:GetService("Debris")
  223. RunService = game:GetService("RunService")
  224.  
  225. BaseUrl = "http://www.roblox.com/asset/?id="
  226.  
  227. Grips = {
  228. Up = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0),
  229. Out = CFrame.new(0, 0, -1.5, 0, -1, -0, -1, 0, -0, 0, 0, -1),
  230. }
  231.  
  232. DamageValues = {
  233. BaseDamage = 5,
  234. SlashDamage = 10,
  235. LungeDamage = 30,
  236. }
  237.  
  238. Damage = DamageValues.BaseDamage
  239.  
  240. Sounds = {
  241. Slash = Handle:WaitForChild("Slash"),
  242. Lunge = Handle:WaitForChild("Lunge"),
  243. Unsheath = Handle:WaitForChild("Unsheath"),
  244. }
  245.  
  246. LastAttack = 0
  247.  
  248. ToolEquipped = false
  249.  
  250. Tool.Enabled = true
  251.  
  252. function SwordUp()
  253. Tool.Grip = Grips.Up
  254. end
  255.  
  256. function SwordOut()
  257. Tool.Grip = Grips.Out
  258. end
  259.  
  260. function IsTeamMate(Player1, Player2)
  261. return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
  262. end
  263.  
  264. function TagHumanoid(humanoid, player)
  265. local Creator_Tag = Instance.new("ObjectValue")
  266. Creator_Tag.Name = "creator"
  267. Creator_Tag.Value = player
  268. Debris:AddItem(Creator_Tag, 2)
  269. Creator_Tag.Parent = humanoid
  270. end
  271.  
  272. function UntagHumanoid(humanoid)
  273. for i, v in pairs(humanoid:GetChildren()) do
  274. if v:IsA("ObjectValue") and v.Name == "creator" then
  275. v:Destroy()
  276. end
  277. end
  278. end
  279.  
  280. function Attack()
  281. Damage = DamageValues.SlashDamage
  282. Sounds.Slash:Play()
  283. local Anim = Instance.new("StringValue")
  284. Anim.Name = "toolanim"
  285. Anim.Value = "Slash"
  286. Anim.Parent = Tool
  287. end
  288.  
  289. function Lunge()
  290. Damage = DamageValues.LungeDamage
  291. Sounds.Lunge:Play()
  292. local Anim = Instance.new("StringValue")
  293. Anim.Name = "toolanim"
  294. Anim.Value = "Lunge"
  295. Anim.Parent = Tool
  296. local Force = Instance.new("BodyVelocity")
  297. Force.velocity = Vector3.new(0, 10, 0)
  298. Force.maxForce = Vector3.new(0, 4000, 0)
  299. Debris:AddItem(Force, 0.5)
  300. Force.Parent = RootPart
  301. wait(0.25)
  302. SwordOut()
  303. wait(0.25)
  304. if Force and Force.Parent then
  305. Force:Destroy()
  306. end
  307. wait(0.5)
  308. SwordUp()
  309. end
  310.  
  311. function Blow(Hit)
  312. if not Hit or not Hit.Parent or not CheckIfAlive() then
  313. return
  314. end
  315. local RightArm = (Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand"))
  316. if not RightArm then
  317. return
  318. end
  319. local RightGrip = RightArm:FindFirstChild("RightGrip")
  320. if not RightGrip or (RightGrip.Part0 ~= RightArm and RightGrip.Part1 ~= RightArm) or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
  321. return
  322. end
  323. local character = Hit.Parent
  324. local humanoid = character:FindFirstChild("Humanoid")
  325. if not humanoid then
  326. return
  327. end
  328. local player = Players:GetPlayerFromCharacter(character)
  329. if player and (player == Player or IsTeamMate(Player, player)) then
  330. return
  331. end
  332. UntagHumanoid(humanoid)
  333. TagHumanoid(humanoid, Player)
  334. humanoid:TakeDamage(Damage)
  335. end
  336.  
  337. function Activated()
  338. if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
  339. return
  340. end
  341. Tool.Enabled = false
  342. local Tick = RunService.Stepped:wait()
  343. if (Tick - LastAttack) < 0.2 then
  344. Lunge()
  345. else
  346. Attack()
  347. end
  348. Damage = DamageValues.BaseDamage
  349. LastAttack = Tick
  350. Tool.Enabled = true
  351. end
  352.  
  353. function CheckIfAlive()
  354. return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and RootPart and RootPart.Parent and Player and Player.Parent) and true) or false)
  355. end
  356.  
  357. function Equipped()
  358. Character = Tool.Parent
  359. Player = Players:GetPlayerFromCharacter(Character)
  360. Humanoid = Character:FindFirstChild("Humanoid")
  361. RootPart = Character:FindFirstChild("HumanoidRootPart")
  362. if not CheckIfAlive() then
  363. return
  364. end
  365. ToolEquipped = true
  366. Sounds.Unsheath:Play()
  367. end
  368.  
  369. function Unequipped()
  370. ToolEquipped = false
  371. end
  372.  
  373. SwordUp()
  374.  
  375. Handle.Touched:connect(Blow)
  376.  
  377. Tool.Activated:connect(Activated)
  378. Tool.Equipped:connect(Equipped)
  379. Tool.Unequipped:connect(Unequipped)
  380. end,o8)
  381. end))
  382. o9.Name = "MouseIcon"
  383. o9.Parent = o1
  384. table.insert(cors,coroutine.create(function()
  385. wait()
  386. runDummyScript(function()
  387. --Rescripted by Luckymaxer
  388.  
  389. Mouse_Icon = "rbxasset://textures/GunCursor.png"
  390. Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
  391.  
  392. Tool = script.Parent
  393.  
  394. Mouse = nil
  395.  
  396. function UpdateIcon()
  397. if Mouse then
  398. Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
  399. end
  400. end
  401.  
  402. function OnEquipped(ToolMouse)
  403. Mouse = ToolMouse
  404. UpdateIcon()
  405. end
  406.  
  407. function OnChanged(Property)
  408. if Property == "Enabled" then
  409. UpdateIcon()
  410. end
  411. end
  412.  
  413. Tool.Equipped:connect(OnEquipped)
  414. Tool.Changed:connect(OnChanged)
  415.  
  416. end,o9)
  417. end))
  418. o10.Name = "toolanim"
  419. o10.Parent = o1
  420. o10.Value = "Slash"
  421. o11.Name = "toolanim"
  422. o11.Parent = o1
  423. o11.Value = "Slash"
  424. o12.Name = "toolanim"
  425. o12.Parent = o1
  426. o12.Value = "Slash"
  427. o13.Name = "toolanim"
  428. o13.Parent = o1
  429. o13.Value = "Slash"
  430. mas.Parent = workspace
  431. mas:MakeJoints()
  432. local mas1 = mas:GetChildren()
  433. for i=1,#mas1 do
  434. mas1[i].Parent = script
  435. ypcall(function() mas1[i]:MakeJoints() end)
  436. end
  437. mas:Destroy()
  438. for i=1,#cors do
  439. coroutine.resume(cors[i])
  440. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement