Advertisement
UnknownUser25

FE Simple Katana (Short maybe)

Oct 31st, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.56 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. do
  4. print("FE Compatibility code by Mokiros")
  5. script.Parent = Player.Character
  6.  
  7. --RemoteEvent for communicating
  8. local Event = Instance.new("RemoteEvent")
  9. Event.Name = "UserInput_Event"
  10.  
  11. --Fake event to make stuff like Mouse.KeyDown work
  12. local function fakeEvent()
  13. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  14. t.connect = t.Connect
  15. return t
  16. end
  17.  
  18. --Creating fake input objects with fake variables
  19. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  20. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  21. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  22. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  23. end}
  24. --Merged 2 functions into one by checking amount of arguments
  25. CAS.UnbindAction = CAS.BindAction
  26.  
  27. --This function will trigger the events that have been :Connect()'ed
  28. local function te(self,ev,...)
  29. local t = m[ev]
  30. if t and t._fakeEvent and t.Function then
  31. t.Function(...)
  32. end
  33. end
  34. m.TrigEvent = te
  35. UIS.TrigEvent = te
  36.  
  37. Event.OnServerEvent:Connect(function(plr,io)
  38. if plr~=Player then return end
  39. if io.isMouse then
  40. m.Target = io.Target
  41. m.Hit = io.Hit
  42. else
  43. local b = io.UserInputState == Enum.UserInputState.Begin
  44. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  45. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  46. end
  47. for _,t in pairs(CAS.Actions) do
  48. for _,k in pairs(t.Keys) do
  49. if k==io.KeyCode then
  50. t.Function(t.Name,io.UserInputState,io)
  51. end
  52. end
  53. end
  54. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  55. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  56. end
  57. end)
  58. Event.Parent = NLS([==[
  59. local Player = game:GetService("Players").LocalPlayer
  60. local Event = script:WaitForChild("UserInput_Event")
  61.  
  62. local UIS = game:GetService("UserInputService")
  63. local input = function(io,a)
  64. if a then return end
  65. --Since InputObject is a client-side instance, we create and pass table instead
  66. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  67. end
  68. UIS.InputBegan:Connect(input)
  69. UIS.InputEnded:Connect(input)
  70.  
  71. local Mouse = Player:GetMouse()
  72. local h,t
  73. --Give the server mouse data 30 times every second, but only if the values changed
  74. --If player is not moving their mouse, client won't fire events
  75. while wait(1/30) do
  76. if h~=Mouse.Hit or t~=Mouse.Target then
  77. h,t=Mouse.Hit,Mouse.Target
  78. Event:FireServer({isMouse=true,Target=t,Hit=h})
  79. end
  80. end]==],Player.Character)
  81. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  82. end
  83. spawn (function()
  84. -- Objects
  85.  
  86. local Sword = Instance.new("Model")
  87. local Player = owner
  88. local Char = Player.Character
  89. local BaseAttachment = Instance.new("Attachment")
  90. local BladeAttackment = Instance.new("Attachment")
  91. local Blade = Instance.new("Part")
  92. local Trail = Instance.new("Trail")
  93. local RunService = game:GetService("RunService")
  94. local Handle = Instance.new("Part")
  95. local HandleToBlade = Instance.new("Weld")
  96. local HandToTorso = Instance.new("Weld")
  97. local HandleToHand = Instance.new("Weld")
  98. local BladeToSharp = Instance.new("Weld")
  99. local Sharp = Instance.new("WedgePart")
  100. local Slash = false
  101. local Blood = Instance.new("Part")
  102. local BloodCont = Instance.new("Model")
  103. local Smoothner = Instance.new("BlockMesh")
  104. local Attacking = false
  105. local HitSound = Instance.new("Sound")
  106. local SlashSound = Instance.new("Sound")
  107. local CFrames =
  108. {
  109. t_HandToTorso =
  110. {
  111. BackClick = CFrame.new(-1.5, 1, 0) * CFrame.Angles(3.5, 0, 0),
  112. BackStab = CFrame.new(-1.5, 0.5, -0.5) * CFrame.Angles(1.5, 0, 0),
  113. FrontClick = CFrame.new(-1.5, 0, 0) * CFrame.Angles(0, 0, 0),
  114. FrontStab = CFrame.new(-1.5, 0.5, 0.5) * CFrame.Angles(-1.5, 0, 0)
  115. },
  116. t_HandleToHand =
  117. {
  118. BackClick = CFrame.new(0, 0, 0) * CFrame.Angles(-5, 0.2, 1),
  119. BackStab = CFrame.new(0, 0, 0) * CFrame.Angles(0.3, 0, 0),
  120. FrontClick = CFrame.new(0, 0, 0) * CFrame.Angles(1.5, 0, 0),
  121. FrontStab = CFrame.new(0, 0, 0) * CFrame.Angles(3, 0, 0)
  122. }
  123. }
  124.  
  125. -- Assets
  126.  
  127. game.ContentProvider:Preload("rbxassetid://196969716") -- Trail Texutre
  128. game.ContentProvider:Preload("rbxassetid://158037267") -- Slash Sound
  129. game.ContentProvider:Preload("rbxassetid://186311262") -- Hit Sound
  130.  
  131. -- Properties
  132.  
  133. Sword.Parent = Char
  134. Sword.Name = "Sword"
  135.  
  136. Handle.BrickColor = BrickColor.new("Dark orange")
  137. Handle.Material = "Marble"
  138. Handle.Name = "Handle"
  139. Handle.Anchored = false
  140. Handle.CanCollide = false
  141. Handle.Size = Vector3.new(0.1, 1, 0.35)
  142. Handle.BackSurface = "SmoothNoOutlines"
  143. Handle.BottomSurface = "SmoothNoOutlines"
  144. Handle.FrontSurface = "SmoothNoOutlines"
  145. Handle.LeftSurface = "SmoothNoOutlines"
  146. Handle.RightSurface = "SmoothNoOutlines"
  147. Handle.TopSurface = "SmoothNoOutlines"
  148.  
  149.  
  150. Blade.BrickColor = BrickColor.new("Fossil")
  151. Blade.Material = "Neon"
  152. Blade.Name = "Blade"
  153. Blade.Anchored = false
  154. Blade.CanCollide = false
  155. Blade.Size = Vector3.new(0.1, 4.84, 0.35)
  156. Blade.BackSurface = "SmoothNoOutlines"
  157. Blade.BottomSurface = "SmoothNoOutlines"
  158. Blade.FrontSurface = "SmoothNoOutlines"
  159. Blade.LeftSurface = "SmoothNoOutlines"
  160. Blade.RightSurface = "SmoothNoOutlines"
  161. Blade.TopSurface = "SmoothNoOutlines"
  162.  
  163. Sharp.BrickColor = BrickColor.new("Fossil")
  164. Sharp.Material = "Neon"
  165. Sharp.Name = "Sharp"
  166. Sharp.Anchored = false
  167. Sharp.CanCollide = false
  168. Sharp.Size = Vector3.new(0.1, 1, 0.35)
  169. Sharp.BackSurface = "SmoothNoOutlines"
  170. Sharp.BottomSurface = "SmoothNoOutlines"
  171. Sharp.FrontSurface = "SmoothNoOutlines"
  172. Sharp.LeftSurface = "SmoothNoOutlines"
  173. Sharp.RightSurface = "SmoothNoOutlines"
  174. Sharp.TopSurface = "SmoothNoOutlines"
  175.  
  176. Blood.BrickColor = BrickColor.new("Really red")
  177. Blood.Size = Vector3.new(0.5, 0.3, 0.6)
  178.  
  179. BloodCont.Name = "BloodCont"
  180.  
  181. Smoothner.Parent = Blood
  182.  
  183. BaseAttachment.Parent = Sharp
  184. BladeAttackment.Parent = Blade
  185.  
  186. Trail.Attachment0 = BaseAttachment
  187. Trail.Attachment1 = BladeAttackment
  188. Trail.Parent = Sharp
  189. Trail.Enabled = false
  190. Trail.Transparency = NumberSequence.new(0, 1)
  191. Trail.Texture = "rbxassetid://196969716"
  192. Trail.Lifetime = 0.15
  193.  
  194. SlashSound.Parent = Handle
  195. SlashSound.Name = "SlashSound"
  196. SlashSound.Volume = 0.4
  197. SlashSound.SoundId = "rbxassetid://158037267"
  198.  
  199. HitSound.Parent = Handle
  200. HitSound.Name = "HitSound"
  201. HitSound.Volume = 0.4
  202. HitSound.PlaybackSpeed = 2.4
  203. HitSound.SoundId = "rbxassetid://186311262"
  204.  
  205. -- Welds
  206.  
  207. HandleToBlade.Part0 = Handle
  208. HandleToBlade.C0 = CFrame.new(0, 2.92, 0)
  209. HandleToBlade.Part1 = Blade
  210. HandleToBlade.Name = "HandleToBlade"
  211. HandleToBlade.Parent = Handle
  212.  
  213. BladeToSharp.Part0 = Sharp
  214. BladeToSharp.C0 = CFrame.new(0, -2.92, 0)
  215. BladeToSharp.Part1 = Blade
  216. BladeToSharp.Parent = Handle
  217. BladeToSharp.Name = "BladeToSharp"
  218.  
  219. HandleToHand.Part0 = Handle
  220. HandleToHand.Name = "HandleToHand"
  221. HandleToHand.C0 = CFrame.Angles(1.5, 0, 0)
  222. HandleToHand.C1 = CFrame.new(0, -1, 0)
  223. HandleToHand.Part1 = Char["Right Arm"]
  224. HandleToHand.Parent = Handle
  225.  
  226. HandToTorso.Part0 = Char["Right Arm"]
  227. HandToTorso.Part1 = Char.Torso
  228. HandToTorso.Name = "HandToTorso"
  229. HandToTorso.Parent = Handle
  230. HandToTorso.C0 = CFrame.new(-1.5, 0, 0)
  231.  
  232. Handle.Parent = Sword
  233. Blade.Parent = Sword
  234. Sharp.Parent = Sword
  235.  
  236. -- Functions
  237.  
  238.  
  239. Mouse.Button1Down:Connect(function()
  240. if Slash == false then
  241. CFrames.t_HandleToHand.Back = CFrame.new(0, 0, 0) * CFrame.Angles(-5, math.random(-1, 1.2), 1)
  242. Trail.Enabled = true
  243. Slash = true
  244.  
  245. for Back = 0, 1, 0.05 do
  246. HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.BackClick, Back)
  247. HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.BackClick, Back)
  248. RunService.Stepped:wait()
  249. end
  250.  
  251. SlashSound:Play()
  252.  
  253. for Front = 0, 1, 0.1 do
  254. HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontClick, Front)
  255. HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontClick, Front)
  256. RunService.Stepped:wait()
  257. end
  258.  
  259. Slash = false
  260. Trail.Enabled = false
  261. end
  262. end)
  263.  
  264. Mouse.KeyDown:Connect(function(key)
  265. if key == "q" and Slash == false then
  266. Slash = true
  267. Trail.Enabled = true
  268.  
  269. for Back = 0, 1, 0.025 do
  270. HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.BackStab, Back)
  271. HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.BackStab, Back)
  272. RunService.Stepped:wait()
  273. end
  274.  
  275. SlashSound:Play()
  276.  
  277. for Front = 0, 1, 0.1 do
  278. HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontStab, Front)
  279. HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontStab, Front)
  280. RunService.Stepped:wait()
  281. end
  282.  
  283. for Def = 0, 1, 0.1 do
  284. HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontClick, Def)
  285. HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontClick, Def)
  286. RunService.Stepped:wait()
  287. end
  288.  
  289. Slash = false
  290. Trail.Enabled = false
  291. end
  292. end)
  293.  
  294. Blade.Touched:Connect(function(hit)
  295. if Slash == true and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= game.Players.LocalPlayer.Character and Attacking == false then
  296. hit.Parent.Humanoid:TakeDamage(math.random(10, 20))
  297. Handle.HitSound.Playing = true
  298. Attacking = true
  299. BloodCont.Parent = hit.Parent.Torso
  300. for i = 1, math.random(4, 7) do
  301. local CBlood = Blood:Clone()
  302. CBlood.Parent = BloodCont
  303. CBlood.CFrame = hit.Parent.Torso.CFrame
  304. end
  305. wait(0.5)
  306. BloodCont:Remove()
  307. Attacking = false
  308. end
  309. end)
  310. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement