subaru112g

Apple not done

May 2nd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.29 KB | None | 0 0
  1. warn("Made by Subaru112.")
  2. print("Enjoy!")
  3.  
  4. script:ClearAllChildren()
  5.  
  6. -------------------------------------------------------------------------------------------------------------------
  7. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  8. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  9. do
  10. print("FE Compatibility code by Mokiros")
  11. script.Parent = Player.Character
  12.  
  13. --RemoteEvent for communicating
  14. local Event = Instance.new("RemoteEvent")
  15. Event.Name = "UserInput_Event"
  16.  
  17. --Fake event to make stuff like Mouse.KeyDown work
  18. local function fakeEvent()
  19. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  20. t.connect = t.Connect
  21. return t
  22. end
  23.  
  24. --Creating fake input objects with fake variables
  25. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  26. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  27. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  28. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  29. end}
  30. --Merged 2 functions into one by checking amount of arguments
  31. CAS.UnbindAction = CAS.BindAction
  32.  
  33. --This function will trigger the events that have been :Connect()'ed
  34. local function te(self,ev,...)
  35. local t = m[ev]
  36. if t and t._fakeEvent and t.Function then
  37. t.Function(...)
  38. end
  39. end
  40. m.TrigEvent = te
  41. UIS.TrigEvent = te
  42.  
  43. Event.OnServerEvent:Connect(function(plr,io)
  44. if plr~=Player then return end
  45. if io.isMouse then
  46. m.Target = io.Target
  47. m.Hit = io.Hit
  48. else
  49. local b = io.UserInputState == Enum.UserInputState.Begin
  50. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  51. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67.  
  68. local UIS = game:GetService("UserInputService")
  69. local input = function(io,a)
  70. if a then return end
  71. --Since InputObject is a client-side instance, we create and pass table instead
  72. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  73. end
  74. UIS.InputBegan:Connect(input)
  75. UIS.InputEnded:Connect(input)
  76.  
  77. local Mouse = Player:GetMouse()
  78. local h,t
  79. --Give the server mouse data 30 times every second, but only if the values changed
  80. --If player is not moving their mouse, client won't fire events
  81. while wait(1/30) do
  82. if h~=Mouse.Hit or t~=Mouse.Target then
  83. h,t=Mouse.Hit,Mouse.Target
  84. Event:FireServer({isMouse=true,Target=t,Hit=h})
  85. end
  86. end]==],Player.Character)
  87. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  88. end
  89. -------------------------------------------------------------------------------------------------------------------
  90.  
  91. local mus = Instance.new("Sound",owner.Character)
  92. game.Debris:AddItem(mus,0.05)
  93.  
  94. ArtificialHB = Instance.new("BindableEvent", script)
  95. ArtificialHB.Name = "Heartbeat"
  96. script:WaitForChild("Heartbeat")
  97. frame = 0.03333333333333
  98. tf = 0
  99. allowframeloss = false
  100. tossremainder = false
  101. lastframe = tick()
  102. script.Heartbeat:Fire()
  103. game:GetService("RunService").Heartbeat:connect(function(s, p)
  104. tf = tf + s
  105. if tf >= frame then
  106. if allowframeloss then
  107. script.Heartbeat:Fire()
  108. lastframe = tick()
  109. else
  110. for i = 1, math.floor(tf / frame) do
  111. script.Heartbeat:Fire()
  112. end
  113. lastframe = tick()
  114. end
  115. if tossremainder then
  116. tf = 0
  117. else
  118. tf = tf - frame * math.floor(tf / frame)
  119. end
  120. end
  121. end)
  122.  
  123. function clerp(a, b, t)
  124. return a:lerp(b, t)
  125. end
  126.  
  127. function swait(num)
  128. if num == 0 or num == nil then
  129. ArtificialHB.Event:wait()
  130. else
  131. for i = 0, num do
  132. ArtificialHB.Event:wait()
  133. end
  134. end
  135. end
  136.  
  137. function rayCast(Position, Direction, Range, Ignore)
  138. return game:service("Workspace"):FindPartOnRay(Ray.new(Position, Direction.unit * (Range or 999.999)), Ignore)
  139. end
  140.  
  141. local sine = 0
  142. local change = 1
  143.  
  144. local plr = owner
  145. local char = plr.Character
  146. local chara = char
  147. angles = CFrame.Angles
  148. Rad = math.rad
  149. local RootPart = chara.HumanoidRootPart
  150. local RootJoint = RootPart.RootJoint
  151. local Create = LoadLibrary("RbxUtility").Create
  152. local debby = game:GetService("Debris")
  153. local Humanoid = char:FindFirstChildOfClass("Humanoid")
  154. Humanoid.WalkSpeed = 10
  155. Humanoid.Animator.Parent = nil
  156. chara.Animate.Parent = nil
  157. local attack = false
  158. local Anim = 'Idle'
  159. local Torsovelocity = (RootPart.Velocity * Vector3.new(1, 0, 1)).magnitude
  160. local velocity = RootPart.Velocity.y
  161. Humanoid.MaxHealth = 100000000000000000000000000
  162. local Torso,Head,LeftArm,RightArm,LeftLeg,RightLeg,Root = char.Torso,char.Head,char["Left Arm"],char["Right Arm"],char["Left Leg"],char["Right Leg"],char.HumanoidRootPart
  163. local ff = Instance.new("ForceField",char)
  164. ff.Visible = false
  165.  
  166. Humanoid.BreakJointsOnDeath = false
  167.  
  168. local newMotor = function(part0, part1, c0, c1)
  169. local w = Create('Motor'){
  170. Parent = part0,
  171. Part0 = part0,
  172. Part1 = part1,
  173. C0 = c0,
  174. C1 = c1,
  175. }
  176. return w
  177. end
  178.  
  179. local RW = newMotor(Torso, RightArm, CFrame.new(1.5, 0, 0), CFrame.new(0, 0, 0))
  180. local LW = newMotor(Torso, LeftArm, CFrame.new(-1.5, 0, 0), CFrame.new(0, 0, 0))
  181. local RH = newMotor(Torso, RightLeg, CFrame.new(.5, -2, 0), CFrame.new(0, 0, 0))
  182. local LH = newMotor(Torso, LeftLeg, CFrame.new(-.5, -2, 0), CFrame.new(0, 0, 0))
  183. RootJoint.C1 = CFrame.new(0, 0, 0)
  184. RootJoint.C0 = CFrame.new(0, 0, 0)
  185. Torso.Neck.C1 = CFrame.new(0, 0, 0)
  186. Torso.Neck.C0 = CFrame.new(0, 1.5, 0)
  187.  
  188. local rarmc1 = RW.C1
  189. local larmc1 = LW.C1
  190. local rlegc1 = RH.C1
  191. local llegc1 = LH.C1
  192.  
  193. local resetc1 = false
  194.  
  195. function PlayAnimationFromTable(table, speed, bool)
  196. RootJoint.C0 = clerp(RootJoint.C0, table[1], speed)
  197. Torso.Neck.C0 = clerp(Torso.Neck.C0, table[2], speed)
  198. RW.C0 = clerp(RW.C0, table[3], speed)
  199. LW.C0 = clerp(LW.C0, table[4], speed)
  200. RH.C0 = clerp(RH.C0, table[5], speed)
  201. LH.C0 = clerp(LH.C0, table[6], speed)
  202. if bool == true then
  203. if resetc1 == false then
  204. resetc1 = true
  205. RootJoint.C1 = RootJoint.C1
  206. Torso.Neck.C1 = Torso.Neck.C1
  207. RW.C1 = rarmc1
  208. LW.C1 = larmc1
  209. RH.C1 = rlegc1
  210. LH.C1 = llegc1
  211. end
  212. end
  213. end
  214.  
  215. local apple = Instance.new("Part",char)
  216. apple.Size = Vector3.new(1,1,1)
  217. apple.Name = "apple"
  218. apple.CanCollide = false
  219. apple.BrickColor = BrickColor.new("Really black")
  220. apple.Transparency = 0
  221. local m = Instance.new("SpecialMesh",apple)
  222. m.MeshType = "FileMesh"
  223. m.Scale = Vector3.new(2, 2, 2)
  224. m.MeshId = "http://www.roblox.com/asset/?id=16190555"
  225. m.TextureId = "http://www.roblox.com/asset/?id=16190577"
  226. m.VertexColor = Vector3.new(3, 3, 3)
  227. local w1 = Instance.new("Weld",char)
  228. w1.Part0 = RightArm
  229. w1.Part1 = apple
  230. w1.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  231. w1.C1 = CFrame.new(0.146064758, -0.115692139, -1.00712729, -0.99619472, 0.0871557593, 0, 0, 0, -1, -0.0871557593, -0.99619472, 0)
  232.  
  233. function eat()
  234. if attack == false then
  235. mus:Play()
  236. attack = true
  237. Humanoid.WalkSpeed = 2
  238. for i=0,1,.3 do
  239. swait()
  240. PlayAnimationFromTable({
  241. CFrame.new(-0.0769465268, -7.7815578e-08, -0.031559173, 0.939695537, 1.01607293e-06, 0.342021346, 7.9855522e-07, 1.00000191, 5.12654879e-07, -0.342019558, 2.16066837e-07, 0.939692855),
  242. CFrame.new(0, 1.52556515, -0.222141266, 1, 0, 0, 0, 0.965925753, 0.258819461, 0, -0.258819461, 0.965925753),
  243. CFrame.new(1.41317558, 0.534107685, -0.455181122, 0.98480773, 0, 0.173648179, 0.172987401, -0.0871557668, -0.981060266, 0.0151344398, 0.99619472, -0.085831672),
  244. CFrame.new(-0.902302742, 0.228387356, 0.45406723, 0.571393847, -0.819151998, 0.0499903709, 0.515395641, 0.405579865, 0.754898906, -0.638652086, -0.405579776, 0.653933227),
  245. CFrame.new(0.500003159, -2.00000715, -1.98185444e-06, 0.939692736, 0, -0.342019916, 0, 1, 0, 0.342019886, 0, 0.939692736) * CFrame.new(0,-.05 * math.cos((sine)/10), 0),
  246. CFrame.new(-0.500018835, -2.0000062, 2.08616257e-07, 0.939692438, 0, 0.342020929, 0, 1, 0, -0.342020959, 0, 0.939692438) * CFrame.new(0,-.05 * math.cos((sine)/10), 0),
  247. }, .5, false)
  248. end
  249. Humanoid.WalkSpeed = 10
  250. attack = false
  251. end
  252. end
  253.  
  254. Mouse.Button1Down:connect(function()
  255. eat()
  256. end)
  257.  
  258. Mouse.KeyDown:connect(function(k)
  259. k = k:lower()
  260. if k=='e' then
  261.  
  262. end
  263. end)
  264.  
  265. -- Animations
  266. while game:GetService("RunService").Heartbeat:Wait() do
  267. Humanoid.JumpPower = 50
  268. Humanoid.MaxHealth = 1000000000000000000000000000000
  269. Humanoid.Health = Humanoid.MaxHealth
  270. Torsovelocity = (RootPart.Velocity * Vector3.new(1, 0, 1)).magnitude
  271. velocity = RootPart.Velocity.y
  272. sine = sine + change
  273. local hit, pos = rayCast(RootPart.Position, (CFrame.new(RootPart.Position, RootPart.Position - Vector3.new(0, 1, 0))).lookVector, 4, chara)
  274. if RootPart.Velocity.y > 1 and hit == nil then
  275. Anim = "Jump"
  276. if attack == false then
  277. PlayAnimationFromTable({
  278. CFrame.new(0, 0.0382082276, -0.0403150208, 1, 0, 0, 0, 0.984807849, 0.173647985, 0, -0.173647985, 0.984807849),
  279. CFrame.new(0, 1.46579528, 0.0939689279, 1, 0, 0, 0, 0.939692855, -0.342019796, 0, 0.342019796, 0.939692855),
  280. CFrame.new(1.20945489, -0.213504896, 3.55388607e-07, 0.939692736, 0.342019916, 1.53461215e-07, -0.342019945, 0.939692736, 1.93715096e-07, -8.56816769e-08, -2.23517418e-07, 1.00000012),
  281. CFrame.new(-1.20945573, -0.213503733, 5.0439985e-07, 0.939692736, -0.342019916, -1.53461215e-07, 0.342019945, 0.939692736, 1.93715096e-07, 8.56816769e-08, -2.23517418e-07, 1.00000012),
  282. CFrame.new(0.5, -1.99739456, -0.0180913229, 1, 0, 0, 0, 1.00000012, 0, 0, 0, 1.00000012),
  283. CFrame.new(-0.5, -1.30000103, -0.39999947, 1, 0, 0, 0, 0.939692676, 0.342020601, 0, -0.342020601, 0.939692676),
  284. }, .3, false)
  285. end
  286. elseif RootPart.Velocity.y < -1 and hit == nil then
  287. Anim = "Fall"
  288. if attack == false then
  289. PlayAnimationFromTable({
  290. CFrame.new(0, -0.0646628663, 0.0399149321, 1, 0, 0, 0, 0.984807849, -0.173647985, 0, 0.173647985, 0.984807849),
  291. CFrame.new(0, 1.4913609, -0.128171027, 1, 0, 0, 0, 0.939692855, 0.342019796, 0, -0.342019796, 0.939692855),
  292. CFrame.new(1.55285025, 0.466259956, -9.26282269e-08, 0.766043842, -0.642788351, -6.46188241e-08, 0.642788291, 0.766043961, -7.4505806e-08, 1.04308128e-07, 1.49011612e-08, 1.00000012),
  293. CFrame.new(-1.5605253, 0.475036323, -2.10609159e-07, 0.766043842, 0.642788351, 6.46188241e-08, -0.642788291, 0.766043961, -7.4505806e-08, -1.04308128e-07, 1.49011612e-08, 1.00000012),
  294. CFrame.new(0.500000954, -1.9973948, -0.0180922765, 1, 0, 0, 0, 1.00000012, 0, 0, 0, 1.00000012),
  295. CFrame.new(-0.499999046, -1.30000043, -0.400000483, 1, 0, 0, 0, 0.939692855, 0.342019796, 0, -0.342019796, 0.939692855),
  296. }, .3, false)
  297. end
  298. elseif Torsovelocity < 1 and hit ~= nil then
  299. Anim = "Idle"
  300. if attack == false then
  301. change = 1
  302. PlayAnimationFromTable({
  303. CFrame.new(-0.0769465268, -7.7815578e-08, -0.031559173, 0.939695537, 1.01607293e-06, 0.342021346, 7.9855522e-07, 1.00000191, 5.12654879e-07, -0.342019558, 2.16066837e-07, 0.939692855) * CFrame.new(0,.05 * math.cos((sine)/10), 0),
  304. CFrame.new(0, 1.52556515, -0.222141266, 1, 0, 0, 0, 0.965925753, 0.258819461, 0, -0.258819461, 0.965925753),
  305. CFrame.new(1.48149872, 0.107130051, 0, 0.99619472, -0.0871557593, 0, 0.0871557593, 0.99619472, 0, 0, 0, 1),
  306. CFrame.new(-1.49128723, 0.0996193886, 0, 0.99619472, 0.087155737, 0, -0.087155737, 0.99619472, 0, 0, 0, 1),
  307. CFrame.new(0.500003159, -2.00000715, -1.98185444e-06, 0.939692736, 0, -0.342019916, 0, 1, 0, 0.342019886, 0, 0.939692736) * CFrame.new(0,-.05 * math.cos((sine)/10), 0),
  308. CFrame.new(-0.500018835, -2.0000062, 2.08616257e-07, 0.939692438, 0, 0.342020929, 0, 1, 0, -0.342020959, 0, 0.939692438) * CFrame.new(0,-.05 * math.cos((sine)/10), 0),
  309. }, .1, false)
  310. end
  311. elseif Torsovelocity > 2 and hit ~= nil then
  312. Anim = "Walk"
  313. if attack == false then
  314. Humanoid.WalkSpeed = 10
  315. PlayAnimationFromTable({
  316. CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) * CFrame.new(0, 0- .08 * math.cos((sine) / 2.5), 0) * CFrame.Angles(0, 0, 0),
  317. CFrame.new(0, 1.52556515, -0.222141266, 1, 0, 0, 0, 0.965925753, 0.258819461, 0, -0.258819461, 0.965925753),
  318. CFrame.new(1.48149872, 0.107130051, 0, 0.99619472, -0.0871557593, 0, 0.0871557593, 0.99619472, 0, 0, 0, 1) * CFrame.new(0, 0, 0+ .5 * math.cos((sine) / 5)),
  319. CFrame.new(-1.49128723, 0.0996193886, 0, 0.99619472, 0.087155737, 0, -0.087155737, 0.99619472, 0, 0, 0, 1) * CFrame.Angles(math.rad(0 - 30 * math.cos((sine) / 5)), 0, 0),
  320. CFrame.new(0.540300786, -1.99793816, -9.82598067e-07, 0.998698533, -0.0510031395, 6.36324955e-07, 0.0510031395, 0.998698533, -1.00461093e-05, -8.35937328e-08, 1.08393433e-05, 1.00000024) * CFrame.new(0, 0, 0+ .5 * math.cos((sine) / 5)) * CFrame.Angles(math.rad(0 - 30 * math.cos((sine) / 5)), 0, 0) * CFrame.new(0, 0, 0- .5 * math.cos((sine) / 5)) * CFrame.Angles(math.rad(0 + 30 * math.cos((sine) / 5)), 0, 0),
  321. CFrame.new(-0.539563596, -1.99794078, 1.12228372e-06, 0.998635888, 0.0523072146, -1.77852357e-07, -0.0523072146, 0.998635888, -1.00715051e-05, -3.89727461e-07, 1.08406466e-05, 1.00000024) * CFrame.new(0, 0, 0- .5 * math.cos((sine) / 5)) * CFrame.Angles(math.rad(0 + 30 * math.cos((sine) / 5)), 0, 0),
  322. }, .3, false)
  323. end
  324. end
  325.  
  326. if mus.Parent == char then
  327. mus.SoundId = "http://www.roblox.com/asset/?id=12544690"
  328. mus.Volume = 1
  329. mus.Pitch = 1
  330. else
  331. mus = Instance.new("Sound",char)
  332. end
  333. end
Add Comment
Please, Sign In to add comment