Advertisement
lafur

Untitled

Nov 3rd, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  4. local RealPlayer = Player
  5. 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(),Button2Up=c(),Button2Down=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;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")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 typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u 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 rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},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")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end do --CFrame lerp (stravant, clerp by AntiBoomz0r)
  6. local function QuaternionFromCFrame(cf)
  7. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  8. local trace = m00 + m11 + m22
  9. if trace > 0 then
  10. local s = math.sqrt(1 + trace)
  11. local recip = 0.5/s
  12. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  13. else
  14. local i = 0
  15. if m11 > m00 then
  16. i = 1
  17. end
  18. if m22 > (i == 0 and m00 or m11) then
  19. i = 2
  20. end
  21. if i == 0 then
  22. local s = math.sqrt(m00-m11-m22+1)
  23. local recip = 0.5/s
  24. return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  25. elseif i == 1 then
  26. local s = math.sqrt(m11-m22-m00+1)
  27. local recip = 0.5/s
  28. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  29. elseif i == 2 then
  30. local s = math.sqrt(m22-m00-m11+1)
  31. local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  32. end
  33. end
  34. end
  35. local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  36. local xs, ys, zs = x + x, y + y, z + z
  37. local wx, wy, wz = w*xs, w*ys, w*zs
  38. local xx = x*xs
  39. local xy = x*ys
  40. local xz = x*zs
  41. local yy = y*ys
  42. local yz = y*zs
  43. local zz = z*zs
  44. return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  45. end
  46. local function QuaternionSlerp(a, b, t)
  47. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  48. local startInterp, finishInterp;
  49. if cosTheta >= 0.0001 then
  50. if (1 - cosTheta) > 0.0001 then
  51. local theta = math.acos(cosTheta)
  52. local invSinTheta = 1/math.sin(theta)
  53. startInterp = math.sin((1-t)*theta)*invSinTheta
  54. finishInterp = math.sin(t*theta)*invSinTheta
  55. else
  56. startInterp = 1-t
  57. finishInterp = t
  58. end
  59. else
  60. if (1+cosTheta) > 0.0001 then
  61. local theta = math.acos(-cosTheta)
  62. local invSinTheta = 1/math.sin(theta)
  63. startInterp = math.sin((t-1)*theta)*invSinTheta
  64. finishInterp = math.sin(t*theta)*invSinTheta
  65. else
  66. startInterp = t-1
  67. finishInterp = t
  68. end
  69. end
  70. return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp
  71. end
  72. function clerp(a,b,t)
  73. local qa = {QuaternionFromCFrame(a)}
  74. local qb = {QuaternionFromCFrame(b)}
  75. local ax, ay, az = a.x, a.y, a.z
  76. local bx, by, bz = b.x, b.y, b.z
  77. local _t = 1-t
  78. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  79. end
  80. end
  81.  
  82.  
  83. do --rayCast
  84. function rayCast(startpos, Speed, Gravity, Dmg)
  85. local ran,err = ypcall(function()
  86. local rayPart = Instance.new("Part", char)
  87. rayPart.Name = "RayPart"
  88. rayPart.BrickColor = BrickColor.new("Really red")
  89. rayPart.Anchored = true
  90. rayPart.Shape = Shape or "Ball"
  91. rayPart.CanCollide = false
  92. rayPart.Locked = true
  93. rayPart.TopSurface = Enum.SurfaceType.Smooth
  94. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  95. rayPart.Size = Vector3.new(.2, 2, .2)
  96. local msh = Instance.new("SpecialMesh",rayPart)
  97. msh.MeshId = "http://www.roblox.com/asset/?id=16190555"
  98. msh.TextureId = "http://www.roblox.com/asset/?id=16190577"
  99. msh.Scale = Vector3.new(2, 2, 2)
  100.  
  101.  
  102.  
  103.  
  104. local bulletposition = startpos.Position
  105. rayPart.CFrame = startpos.CFrame
  106.  
  107. local bulletvelocity = (Vector3.new(math.random(-2,2), math.random(-2,2), math.random(-2,2)))+( mouse.Hit.p - bulletposition).unit*Speed
  108. local bulletlastposition = bulletposition
  109.  
  110.  
  111.  
  112. coroutine.resume(coroutine.create(function()
  113. while true do
  114. local dt = wait()
  115. bulletlastposition = bulletposition
  116. bulletvelocity = bulletvelocity + (Vector3.new(0, -3.81*Gravity, 0)*dt)
  117. bulletposition = bulletposition + (bulletvelocity*dt)
  118.  
  119. local ray = Ray.new(bulletlastposition, (bulletposition - bulletlastposition))
  120.  
  121. local hit, hitposition = workspace:FindPartOnRayWithIgnoreList( ray, { char, rayPart, camera} )
  122.  
  123. if (torso.Position - rayPart.Position).magnitude > 540 then
  124. rayPart:Destroy()
  125. break
  126. end
  127.  
  128.  
  129. if hit then
  130. local damage = math.random(Dmg, Dmg+6)
  131. if hit.Parent:findFirstChild("Humanoid") ~= nil then
  132. hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
  133. elseif hit.Parent:IsA("Hat") and hit.Parent.Parent:findFirstChild("Humanoid") then
  134. hit.Parent.Parent.Humanoid.Health = hit.Parent.Parent.Humanoid.Health - damage
  135. end
  136. bulletposition = hitposition
  137. rayPart.CFrame = CFrame.new(bulletposition, bulletposition+bulletvelocity) * CFrame.Angles(math.pi/2, 0, 0)
  138. for i = 1, 50 do
  139. local s = Instance.new("Part")
  140. s.CanCollide = false
  141. s.Shape = 1
  142. s.Locked = true
  143. s.formFactor = "Custom"
  144. pl = Instance.new("PointLight", s)
  145. pl.Range = 8
  146. pl.Color = Color3.new(0.8, 0.8, 0)
  147. s.Size = Vector3.new(.3,.3,.3)
  148. s.Transparency = 0.5
  149. s.BrickColor = BrickColor.new("Brick yellow")
  150. local v = Vector3.new(math.random(-1,1), math.random(1,2), math.random(-1,1))
  151. s.Velocity = 0.5 * v
  152. s.CFrame = CFrame.new(rayPart.Position + v, v)
  153. s.Parent = workspace
  154. coroutine.resume(coroutine.create(function()
  155. wait(2)
  156. s:Destroy()
  157. end))
  158. end
  159. rayPart:Destroy()
  160. break
  161. end
  162. rayPart.CFrame = CFrame.new(bulletposition, bulletposition+bulletvelocity) * CFrame.Angles(math.pi/2, 0, 0)
  163. rayPart.Parent = workspace
  164. end
  165. end))
  166. end)
  167. if not ran and err then
  168. print(err)
  169. end
  170. end
  171. end
  172.  
  173. do --the animating
  174. plr = game:service'Players'.LocalPlayer
  175. char = plr.Character
  176. mouse = plr:GetMouse()
  177. humanoid = char:findFirstChild("Humanoid")
  178. torso = char:findFirstChild("Torso")
  179. head = char.Head
  180. ra = char:findFirstChild("Right Arm")
  181. la = char:findFirstChild("Left Arm")
  182. rl = char:findFirstChild("Right Leg")
  183. ll = char:findFirstChild("Left Leg")
  184. rs = torso:findFirstChild("Right Shoulder")
  185. ls = torso:findFirstChild("Left Shoulder")
  186. rh = torso:findFirstChild("Right Hip")
  187. lh = torso:findFirstChild("Left Hip")
  188. neck = torso:findFirstChild("Neck")
  189. rj = char:findFirstChild("HumanoidRootPart"):findFirstChild("RootJoint")
  190. anim = char:findFirstChild("Animate")
  191. rootpart = char:findFirstChild("HumanoidRootPart")
  192. camera = workspace.CurrentCamera
  193.  
  194.  
  195. local rm = Instance.new("Weld", torso)
  196. rm.C0 = CFrame.new(1.5, 0.5, 0)
  197. rm.C1 = CFrame.new(0, 0.5, 0)
  198. rm.Part0 = torso
  199. rm.Part1 = ra
  200. local lm = Instance.new("Weld", torso)
  201. lm.C0 = CFrame.new(-1.5, 0.5, 0)
  202. lm.C1 = CFrame.new(0, 0.5, 0)
  203. lm.Part0 = torso
  204. lm.Part1 = la
  205.  
  206.  
  207.  
  208. local speed = 0.3
  209. local angle = 0
  210. local anglespeed = 1
  211. rsc0 = rm.C0
  212. lsc0 = lm.C0
  213. rjc0 = rj.C0
  214. neckc0 = neck.C0
  215. radian = math.rad
  216.  
  217. apple = Instance.new("Part", char)
  218. apple.FormFactor = "Custom"
  219. apple.Size = Vector3.new(1, 1, 1)
  220. apple:breakJoints()
  221. local wld = Instance.new("Weld", char)
  222. wld.C1 = CFrame.new(0, -1, 0)
  223. wld.C0 = CFrame.Angles(math.pi, 0, 0)
  224. wld.Part1 = ra
  225. wld.Part0 = apple
  226. local msh = Instance.new("SpecialMesh", apple)
  227. msh.MeshId = "http://www.roblox.com/asset/?id=16190555"
  228. msh.TextureId = "http://www.roblox.com/asset/?id=16190577"
  229. msh.Scale = Vector3.new(2, 2, 2)
  230.  
  231.  
  232.  
  233. mouse.Button1Down:connect(function()
  234. if throwing then return end
  235. throwing = true
  236. wait(wait()*8)
  237. for trans = 1, 0, -0.1 do
  238. apple.Transparency = trans
  239. wait()
  240. end
  241. end)
  242.  
  243. done = false
  244. while wait() do
  245. angle = (angle % 100) + anglespeed/10
  246. mvmnt = math.pi * math.sin(math.pi*2/100*(angle*10))
  247. local rscf = rsc0
  248. local lscf = lsc0
  249. local rjcf = rjc0
  250. local ncf = neckc0
  251. lscf = lsc0 * CFrame.Angles(-radian(5), 0, -radian(5))
  252. if throwing then
  253. for waiting = 0, 250, 30 do
  254. if done then return end
  255. rscf = rsc0 * CFrame.Angles(radian(waiting), 0, 0)
  256. rm.C0 = clerp(rm.C0,rscf,speed)
  257. wait()
  258. if waiting == 250 then
  259. done = true
  260. end
  261. end
  262. rscf = rsc0 * CFrame.Angles(radian(120), 0, 0)
  263. rayCast(apple, math.random(140, 150), 20, 28)
  264. throwing = false
  265. done = false
  266. end
  267. rm.C0 = clerp(rm.C0,rscf,speed)
  268. lm.C0 = clerp(lm.C0,lscf,speed)
  269. rj.C0 = clerp(rj.C0,rjcf,speed)
  270. neck.C0 = clerp(neck.C0,ncf,speed)
  271. end
  272. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement