Prephy

Sword

Oct 23rd, 2020 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 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. local RealPlayer = Player
  4. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end,__call=function(self,...)local t=rawget(self,"_RealService")if t then return t(...)end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return self[t]end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;x.RunService=v({RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")setmetatable(x,{__index=function(self,t)return r:GetService(t)or typeof(r[t])=="function"and function(m,...)return r[t](r,...)end or r[t]end,__newindex=s.__newindex,__call=s.__call})game,owner=x,x.Players.LocalPlayer end
  5.  
  6. wait(0.2)
  7.  
  8. print("Finding player... (This may take a little!)")
  9. wait (1)
  10. print("Found player. Now giving the sword.")
  11. local user = game.Players.LocalPlayer.Backpack
  12. local sword = Instance.new("Tool",user)
  13. print("Gave the player the sword. Enjoy!")
  14. local handle = Instance.new("Part",sword)
  15. local mesh = Instance.new("SpecialMesh",handle)
  16. local DAMAGE = 35
  17. local sound = Instance.new("Sound",handle)
  18. local sound2 = Instance.new("Sound",handle)
  19. sword.Name = "Sword"
  20. script.Parent = sword
  21. script.Name = "SwordScript"
  22. --local animation = Instance.new("Animation",script)
  23.  
  24. --animation.AnimationId = "http://www.roblox.com/Asset?ID=992817684"
  25.  
  26. sound.SoundId = "rbxasset://sounds//swordlunge.wav"
  27. sound.Volume = 3
  28. sound.PlaybackSpeed = 1.17
  29. sound.Name = "Slash"
  30. sound2.SoundId = "rbxasset://sounds//unsheath.wav"
  31. sound2.Volume = 3
  32. sound2.PlaybackSpeed = 0.8
  33. sound2.Volume = 3
  34. sound2.Name = "Unsheath"
  35.  
  36. function unsheathanimation()
  37. sword.GripPos = sword.GripPos + Vector3.new(0,5,0)
  38. for i = 1,5 do
  39. sword.GripPos = sword.GripPos + Vector3.new(0,-1,0)
  40. wait (0.1)
  41. end
  42. end
  43.  
  44. function unsheathsound()
  45. sound2:Play()
  46. end
  47.  
  48. function damage(hit)
  49.  
  50. local h = hit.Parent:FindFirstChild("Humanoid")
  51. if (h ~= nil) then
  52. h:TakeDamage(DAMAGE / 4)
  53. end
  54. end
  55.  
  56. function animate()
  57. --4
  58. sound:Play()
  59. for i = 1,5 do
  60. sword.GripUp = sword.GripUp + Vector3.new(0,0,1)
  61. wait (0)
  62. end
  63. sword.GripUp = sword.GripUp + Vector3.new(0,0,-1)
  64. end
  65. handle.Size = handle.Size + Vector3.new(-4,-1,-2)
  66. handle.Size = handle.Size + Vector3.new(0.6, 3.6, 0.4)
  67. handle.Name = "Handle"
  68.  
  69. mesh.MeshType = "FileMesh"
  70. mesh.MeshId = "http://www.roblox.com/asset/?id=94746028"
  71. mesh.TextureId = "http://www.roblox.com/asset/?ID=94746105"
  72. mesh.Offset = mesh.Offset + Vector3.new(0,1,0)
  73.  
  74. sword.Equipped:connect(unsheathanimation)
  75. sword.Equipped:connect(unsheathsound)
  76. wait(sound2.TimeLength)
  77. sword.Activated:connect(animate)
  78. handle.Touched:connect(damage)
Add Comment
Please, Sign In to add comment