Advertisement
doryna2281337

Untitled

Aug 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.86 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.  
  84.  
  85. --Converted with ttyyuu12345's model to script plugin v4
  86. function sandbox(var,func)
  87. local env = getfenv(func)
  88. local newenv = setmetatable({},{
  89. __index = function(self,k)
  90. if k=="script" then
  91. return var
  92. else
  93. return env[k]
  94. end
  95. end,
  96. })
  97. setfenv(func,newenv)
  98. return func
  99. end
  100. cors = {}
  101. mas = Instance.new("Model",game:GetService("Lighting"))
  102. Model0 = Instance.new("Model")
  103. Part1 = Instance.new("Part")
  104. Decal2 = Instance.new("Decal")
  105. Sound3 = Instance.new("Sound")
  106. Sound4 = Instance.new("Sound")
  107. Sound5 = Instance.new("Sound")
  108. Sound6 = Instance.new("Sound")
  109. Sound7 = Instance.new("Sound")
  110. Sound8 = Instance.new("Sound")
  111. Sound9 = Instance.new("Sound")
  112. Sound10 = Instance.new("Sound")
  113. Sound11 = Instance.new("Sound")
  114. CylinderMesh12 = Instance.new("CylinderMesh")
  115. Part13 = Instance.new("Part")
  116. Decal14 = Instance.new("Decal")
  117. Motor6D15 = Instance.new("Motor6D")
  118. Motor6D16 = Instance.new("Motor6D")
  119. Motor6D17 = Instance.new("Motor6D")
  120. Motor6D18 = Instance.new("Motor6D")
  121. Motor6D19 = Instance.new("Motor6D")
  122. Part20 = Instance.new("Part")
  123. Part21 = Instance.new("Part")
  124. Part22 = Instance.new("Part")
  125. Part23 = Instance.new("Part")
  126. Humanoid24 = Instance.new("Humanoid")
  127. Part25 = Instance.new("Part")
  128. Motor6D26 = Instance.new("Motor6D")
  129. Script27 = Instance.new("Script")
  130. LocalScript28 = Instance.new("LocalScript")
  131. LocalScript29 = Instance.new("LocalScript")
  132. StringValue30 = Instance.new("StringValue")
  133. Animation31 = Instance.new("Animation")
  134. NumberValue32 = Instance.new("NumberValue")
  135. Animation33 = Instance.new("Animation")
  136. NumberValue34 = Instance.new("NumberValue")
  137. StringValue35 = Instance.new("StringValue")
  138. Animation36 = Instance.new("Animation")
  139. StringValue37 = Instance.new("StringValue")
  140. Animation38 = Instance.new("Animation")
  141. StringValue39 = Instance.new("StringValue")
  142. Animation40 = Instance.new("Animation")
  143. StringValue41 = Instance.new("StringValue")
  144. Animation42 = Instance.new("Animation")
  145. StringValue43 = Instance.new("StringValue")
  146. Animation44 = Instance.new("Animation")
  147. StringValue45 = Instance.new("StringValue")
  148. Animation46 = Instance.new("Animation")
  149. StringValue47 = Instance.new("StringValue")
  150. Animation48 = Instance.new("Animation")
  151. Script49 = Instance.new("Script")
  152. BodyColors50 = Instance.new("BodyColors")
  153. Model0.Name = "oii"
  154. Model0.Parent = mas
  155. Part1.Name = "Head"
  156. Part1.Parent = Model0
  157. Part1.CFrame = CFrame.new(13.7936363, 4.50001431, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  158. Part1.Orientation = Vector3.new(0, -6.40999985, 0)
  159. Part1.Position = Vector3.new(13.7936363, 4.50001431, -22.1235237)
  160. Part1.Rotation = Vector3.new(0, -6.40999985, 0)
  161. Part1.Color = Color3.new(0.803922, 0, 0)
  162. Part1.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  163. Part1.Size = Vector3.new(2, 1, 1)
  164. Part1.BrickColor = BrickColor.new("Really red")
  165. Part1.Locked = true
  166. Part1.TopSurface = Enum.SurfaceType.Smooth
  167. Part1.brickColor = BrickColor.new("Really red")
  168. Part1.FormFactor = Enum.FormFactor.Symmetric
  169. Part1.formFactor = Enum.FormFactor.Symmetric
  170. Decal2.Name = "face"
  171. Decal2.Parent = Part1
  172. Decal2.Texture = "rbxasset://textures/face.png"
  173. Sound3.Name = "GettingUp"
  174. Sound3.Parent = Part1
  175. Sound3.MaxDistance = 150
  176. Sound3.EmitterSize = 5
  177. Sound3.MinDistance = 5
  178. Sound3.SoundId = "rbxasset://sounds/action_get_up.mp3"
  179. Sound3.Volume = 0.64999997615814
  180. Sound4.Name = "Died"
  181. Sound4.Parent = Part1
  182. Sound4.MaxDistance = 150
  183. Sound4.EmitterSize = 5
  184. Sound4.MinDistance = 5
  185. Sound4.SoundId = "rbxasset://sounds/uuhhh.mp3"
  186. Sound4.Volume = 0.64999997615814
  187. Sound5.Name = "FreeFalling"
  188. Sound5.Parent = Part1
  189. Sound5.Looped = true
  190. Sound5.TimePosition = 0.52838909903676
  191. Sound5.MaxDistance = 150
  192. Sound5.EmitterSize = 5
  193. Sound5.MinDistance = 5
  194. Sound5.SoundId = "rbxasset://sounds/action_falling.mp3"
  195. Sound5.Volume = 0
  196. Sound6.Name = "Jumping"
  197. Sound6.Parent = Part1
  198. Sound6.MaxDistance = 150
  199. Sound6.EmitterSize = 5
  200. Sound6.MinDistance = 5
  201. Sound6.SoundId = "rbxasset://sounds/action_jump.mp3"
  202. Sound6.Volume = 0.64999997615814
  203. Sound7.Name = "Landing"
  204. Sound7.Parent = Part1
  205. Sound7.MaxDistance = 150
  206. Sound7.EmitterSize = 5
  207. Sound7.MinDistance = 5
  208. Sound7.SoundId = "rbxasset://sounds/action_jump_land.mp3"
  209. Sound7.Volume = 1
  210. Sound8.Name = "Splash"
  211. Sound8.Parent = Part1
  212. Sound8.MaxDistance = 150
  213. Sound8.EmitterSize = 5
  214. Sound8.MinDistance = 5
  215. Sound8.SoundId = "rbxasset://sounds/impact_water.mp3"
  216. Sound8.Volume = 0.64999997615814
  217. Sound9.Name = "Running"
  218. Sound9.Parent = Part1
  219. Sound9.Looped = true
  220. Sound9.TimePosition = 1.7229757305085
  221. Sound9.MaxDistance = 150
  222. Sound9.EmitterSize = 5
  223. Sound9.MinDistance = 5
  224. Sound9.Pitch = 1.8500000238419
  225. Sound9.PlaybackSpeed = 1.8500000238419
  226. Sound9.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
  227. Sound9.Volume = 0.64999997615814
  228. Sound10.Name = "Swimming"
  229. Sound10.Parent = Part1
  230. Sound10.Looped = true
  231. Sound10.MaxDistance = 150
  232. Sound10.EmitterSize = 5
  233. Sound10.MinDistance = 5
  234. Sound10.Pitch = 1.6000000238419
  235. Sound10.PlaybackSpeed = 1.6000000238419
  236. Sound10.SoundId = "rbxasset://sounds/action_swim.mp3"
  237. Sound10.Volume = 0.64999997615814
  238. Sound11.Name = "Climbing"
  239. Sound11.Parent = Part1
  240. Sound11.Looped = true
  241. Sound11.MaxDistance = 150
  242. Sound11.EmitterSize = 5
  243. Sound11.MinDistance = 5
  244. Sound11.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
  245. Sound11.Volume = 0.64999997615814
  246. CylinderMesh12.Parent = Part1
  247. CylinderMesh12.Scale = Vector3.new(1.29999995, 1.29999995, 1.29999995)
  248. Part13.Name = "Torso"
  249. Part13.Parent = Model0
  250. Part13.CFrame = CFrame.new(13.7936363, 3.00001407, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  251. Part13.Orientation = Vector3.new(0, -6.40999985, 0)
  252. Part13.Position = Vector3.new(13.7936363, 3.00001407, -22.1235237)
  253. Part13.Rotation = Vector3.new(0, -6.40999985, 0)
  254. Part13.Color = Color3.new(1, 1, 0)
  255. Part13.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  256. Part13.Size = Vector3.new(2, 2, 1)
  257. Part13.BrickColor = BrickColor.new("New Yeller")
  258. Part13.LeftParamA = 0
  259. Part13.LeftParamB = 0
  260. Part13.LeftSurface = Enum.SurfaceType.Weld
  261. Part13.Locked = true
  262. Part13.RightParamA = 0
  263. Part13.RightParamB = 0
  264. Part13.RightSurface = Enum.SurfaceType.Weld
  265. Part13.brickColor = BrickColor.new("New Yeller")
  266. Part13.FormFactor = Enum.FormFactor.Symmetric
  267. Part13.formFactor = Enum.FormFactor.Symmetric
  268. Decal14.Name = "roblox"
  269. Decal14.Parent = Part13
  270. Motor6D15.Name = "Right Shoulder"
  271. Motor6D15.Parent = Part13
  272. Motor6D15.MaxVelocity = 0.10000000149012
  273. Motor6D15.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  274. Motor6D15.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  275. Motor6D15.Part0 = Part13
  276. Motor6D15.Part1 = Part21
  277. Motor6D15.part1 = Part21
  278. Motor6D16.Name = "Left Shoulder"
  279. Motor6D16.Parent = Part13
  280. Motor6D16.MaxVelocity = 0.10000000149012
  281. Motor6D16.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  282. Motor6D16.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  283. Motor6D16.Part0 = Part13
  284. Motor6D16.Part1 = Part20
  285. Motor6D16.part1 = Part20
  286. Motor6D17.Name = "Right Hip"
  287. Motor6D17.Parent = Part13
  288. Motor6D17.MaxVelocity = 0.10000000149012
  289. Motor6D17.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  290. Motor6D17.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  291. Motor6D17.Part0 = Part13
  292. Motor6D17.Part1 = Part23
  293. Motor6D17.part1 = Part23
  294. Motor6D18.Name = "Left Hip"
  295. Motor6D18.Parent = Part13
  296. Motor6D18.MaxVelocity = 0.10000000149012
  297. Motor6D18.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  298. Motor6D18.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  299. Motor6D18.Part0 = Part13
  300. Motor6D18.Part1 = Part22
  301. Motor6D18.part1 = Part22
  302. Motor6D19.Name = "Neck"
  303. Motor6D19.Parent = Part13
  304. Motor6D19.MaxVelocity = 0.10000000149012
  305. Motor6D19.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  306. Motor6D19.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  307. Motor6D19.Part0 = Part13
  308. Motor6D19.Part1 = Part1
  309. Motor6D19.part1 = Part1
  310. Part20.Name = "Left Arm"
  311. Part20.Parent = Model0
  312. Part20.CFrame = CFrame.new(12.3029995, 3.00001407, -22.2908611, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  313. Part20.Orientation = Vector3.new(0, -6.40999985, 0)
  314. Part20.Position = Vector3.new(12.3029995, 3.00001407, -22.2908611)
  315. Part20.Rotation = Vector3.new(0, -6.40999985, 0)
  316. Part20.Color = Color3.new(0.803922, 0, 0)
  317. Part20.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  318. Part20.Size = Vector3.new(1, 2, 1)
  319. Part20.BrickColor = BrickColor.new("Really red")
  320. Part20.CanCollide = false
  321. Part20.Locked = true
  322. Part20.brickColor = BrickColor.new("Really red")
  323. Part20.FormFactor = Enum.FormFactor.Symmetric
  324. Part20.formFactor = Enum.FormFactor.Symmetric
  325. Part21.Name = "Right Arm"
  326. Part21.Parent = Model0
  327. Part21.CFrame = CFrame.new(15.2842731, 3.00001407, -21.9561863, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  328. Part21.Orientation = Vector3.new(0, -6.40999985, 0)
  329. Part21.Position = Vector3.new(15.2842731, 3.00001407, -21.9561863)
  330. Part21.Rotation = Vector3.new(0, -6.40999985, 0)
  331. Part21.Color = Color3.new(0.803922, 0, 0)
  332. Part21.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  333. Part21.Size = Vector3.new(1, 2, 1)
  334. Part21.BrickColor = BrickColor.new("Really red")
  335. Part21.CanCollide = false
  336. Part21.Locked = true
  337. Part21.brickColor = BrickColor.new("Really red")
  338. Part21.FormFactor = Enum.FormFactor.Symmetric
  339. Part21.formFactor = Enum.FormFactor.Symmetric
  340. Part22.Name = "Left Leg"
  341. Part22.Parent = Model0
  342. Part22.CFrame = CFrame.new(13.2967577, 1.00001407, -22.1793022, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  343. Part22.Orientation = Vector3.new(0, -6.40999985, 0)
  344. Part22.Position = Vector3.new(13.2967577, 1.00001407, -22.1793022)
  345. Part22.Rotation = Vector3.new(0, -6.40999985, 0)
  346. Part22.Color = Color3.new(1, 1, 0)
  347. Part22.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  348. Part22.Size = Vector3.new(1, 2, 1)
  349. Part22.BottomSurface = Enum.SurfaceType.Smooth
  350. Part22.BrickColor = BrickColor.new("New Yeller")
  351. Part22.CanCollide = false
  352. Part22.Locked = true
  353. Part22.brickColor = BrickColor.new("New Yeller")
  354. Part22.FormFactor = Enum.FormFactor.Symmetric
  355. Part22.formFactor = Enum.FormFactor.Symmetric
  356. Part23.Name = "Right Leg"
  357. Part23.Parent = Model0
  358. Part23.CFrame = CFrame.new(14.2905149, 1.00001407, -22.0677452, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  359. Part23.Orientation = Vector3.new(0, -6.40999985, 0)
  360. Part23.Position = Vector3.new(14.2905149, 1.00001407, -22.0677452)
  361. Part23.Rotation = Vector3.new(0, -6.40999985, 0)
  362. Part23.Color = Color3.new(1, 1, 0)
  363. Part23.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  364. Part23.Size = Vector3.new(1, 2, 1)
  365. Part23.BottomSurface = Enum.SurfaceType.Smooth
  366. Part23.BrickColor = BrickColor.new("New Yeller")
  367. Part23.CanCollide = false
  368. Part23.Locked = true
  369. Part23.brickColor = BrickColor.new("New Yeller")
  370. Part23.FormFactor = Enum.FormFactor.Symmetric
  371. Part23.formFactor = Enum.FormFactor.Symmetric
  372. Humanoid24.Parent = Model0
  373. Humanoid24.LeftLeg = Part22
  374. Humanoid24.RightLeg = Part23
  375. Humanoid24.Torso = Part25
  376. Part25.Name = "HumanoidRootPart"
  377. Part25.Parent = Model0
  378. Part25.CFrame = CFrame.new(13.7936363, 3.00001407, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
  379. Part25.Orientation = Vector3.new(0, -6.40999985, 0)
  380. Part25.Position = Vector3.new(13.7936363, 3.00001407, -22.1235237)
  381. Part25.Rotation = Vector3.new(0, -6.40999985, 0)
  382. Part25.Transparency = 1
  383. Part25.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
  384. Part25.Size = Vector3.new(2, 2, 1)
  385. Part25.BottomSurface = Enum.SurfaceType.Smooth
  386. Part25.CanCollide = false
  387. Part25.LeftParamA = 0
  388. Part25.LeftParamB = 0
  389. Part25.Locked = true
  390. Part25.RightParamA = 0
  391. Part25.RightParamB = 0
  392. Part25.TopSurface = Enum.SurfaceType.Smooth
  393. Part25.FormFactor = Enum.FormFactor.Symmetric
  394. Part25.formFactor = Enum.FormFactor.Symmetric
  395. Motor6D26.Name = "RootJoint"
  396. Motor6D26.Parent = Part25
  397. Motor6D26.MaxVelocity = 0.10000000149012
  398. Motor6D26.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  399. Motor6D26.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  400. Motor6D26.Part0 = Part25
  401. Motor6D26.Part1 = Part13
  402. Motor6D26.part1 = Part13
  403. Script27.Name = "Sound"
  404. Script27.Parent = Model0
  405. table.insert(cors,sandbox(Script27,function()
  406. --[[
  407. Author: @spotco
  408. This script creates sounds which are placed under the character head.
  409. These sounds are used by the "LocalSound" script.
  410.  
  411. To modify this script, copy it to your "StarterPlayer/StarterCharacterScripts" folder keeping the same script name ("Sound").
  412. The default Sound script loaded for every character will then be replaced with your copy of the script.
  413. ]]--
  414.  
  415. function CreateNewSound(name, id, looped, pitch, parent)
  416. local sound = Instance.new("Sound")
  417. sound.SoundId = id
  418. sound.Name = name
  419. sound.archivable = false
  420. sound.Parent = parent
  421. sound.Pitch = pitch
  422. sound.Looped = looped
  423.  
  424. sound.MinDistance = 5
  425. sound.MaxDistance = 150
  426. sound.Volume = 0.65
  427.  
  428. return sound
  429. end
  430.  
  431. local head = script.Parent:FindFirstChild("Head")
  432. if head == nil then
  433. error("Sound script parent has no child Head.")
  434. return
  435. end
  436.  
  437.  
  438. CreateNewSound("GettingUp", "rbxasset://sounds/action_get_up.mp3", false, 1, head)
  439. CreateNewSound("Died", "rbxasset://sounds/uuhhh.mp3", false, 1, head)
  440. CreateNewSound("FreeFalling", "rbxasset://sounds/action_falling.mp3", true, 1, head)
  441. CreateNewSound("Jumping", "rbxasset://sounds/action_jump.mp3", false, 1, head)
  442. CreateNewSound("Landing", "rbxasset://sounds/action_jump_land.mp3", false, 1, head)
  443. CreateNewSound("Splash", "rbxasset://sounds/impact_water.mp3", false, 1, head)
  444. CreateNewSound("Running", "rbxasset://sounds/action_footsteps_plastic.mp3", true, 1.85, head)
  445. CreateNewSound("Swimming", "rbxasset://sounds/action_swim.mp3", true, 1.6, head)
  446. CreateNewSound("Climbing", "rbxasset://sounds/action_footsteps_plastic.mp3", true, 1, head)
  447. end))
  448. LocalScript28.Name = "LocalSound"
  449. LocalScript28.Parent = Script27
  450. table.insert(cors,sandbox(LocalScript28,function()
  451. --[[
  452. Author: @spotco
  453. This script runs locally for the player of the given humanoid.
  454. This script triggers humanoid sound play/pause actions locally.
  455.  
  456. The Playing/TimePosition properties of Sound objects bypass FilteringEnabled, so this triggers the sound
  457. immediately for the player and is replicated to all other players.
  458.  
  459. This script is optimized to reduce network traffic through minimizing the amount of property replication.
  460. ]]--
  461.  
  462. --All sounds are referenced by this ID
  463. local SFX = {
  464. Died = 0;
  465. Running = 1;
  466. Swimming = 2;
  467. Climbing = 3,
  468. Jumping = 4;
  469. GettingUp = 5;
  470. FreeFalling = 6;
  471. FallingDown = 7;
  472. Landing = 8;
  473. Splash = 9;
  474. }
  475.  
  476. local Humanoid = nil
  477. local Head = nil
  478.  
  479. --SFX ID to Sound object
  480. local Sounds = {}
  481.  
  482. do
  483. local Figure = script.Parent.Parent
  484. Head = Figure:WaitForChild("Head")
  485. while not Humanoid do
  486. for _,NewHumanoid in pairs(Figure:GetChildren()) do
  487. if NewHumanoid:IsA("Humanoid") then
  488. Humanoid = NewHumanoid
  489. break
  490. end
  491. end
  492. Figure.ChildAdded:wait()
  493. end
  494.  
  495. Sounds[SFX.Died] = Head:WaitForChild("Died")
  496. Sounds[SFX.Running] = Head:WaitForChild("Running")
  497. Sounds[SFX.Swimming] = Head:WaitForChild("Swimming")
  498. Sounds[SFX.Climbing] = Head:WaitForChild("Climbing")
  499. Sounds[SFX.Jumping] = Head:WaitForChild("Jumping")
  500. Sounds[SFX.GettingUp] = Head:WaitForChild("GettingUp")
  501. Sounds[SFX.FreeFalling] = Head:WaitForChild("FreeFalling")
  502. Sounds[SFX.Landing] = Head:WaitForChild("Landing")
  503. Sounds[SFX.Splash] = Head:WaitForChild("Splash")
  504. end
  505.  
  506. local Util
  507. Util = {
  508.  
  509. --Define linear relationship between (pt1x,pt2x) and (pt2x,pt2y). Evaluate this at x.
  510. YForLineGivenXAndTwoPts = function(x,pt1x,pt1y,pt2x,pt2y)
  511. --(y - y1)/(x - x1) = m
  512. local m = (pt1y - pt2y) / (pt1x - pt2x)
  513. --float b = pt1.y - m * pt1.x;
  514. local b = (pt1y - m * pt1x)
  515. return m * x + b
  516. end;
  517.  
  518. --Clamps the value of "val" between the "min" and "max"
  519. Clamp = function(val,min,max)
  520. return math.min(max,math.max(min,val))
  521. end;
  522.  
  523. --Gets the horizontal (x,z) velocity magnitude of the given part
  524. HorizontalSpeed = function(Head)
  525. local hVel = Head.Velocity + Vector3.new(0,-Head.Velocity.Y,0)
  526. return hVel.magnitude
  527. end;
  528.  
  529. --Gets the vertical (y) velocity magnitude of the given part
  530. VerticalSpeed = function(Head)
  531. return math.abs(Head.Velocity.Y)
  532. end;
  533.  
  534. --Setting Playing/TimePosition values directly result in less network traffic than Play/Pause/Resume/Stop
  535. --If these properties are enabled, use them.
  536. Play = function(sound)
  537. if sound.TimePosition ~= 0 then
  538. sound.TimePosition = 0
  539. end
  540. if not sound.IsPlaying then
  541. sound.Playing = true
  542. end
  543. end;
  544. Pause = function(sound)
  545. if sound.IsPlaying then
  546. sound.Playing = false
  547. end
  548. end;
  549. Resume = function(sound)
  550. if not sound.IsPlaying then
  551. sound.Playing = true
  552. end
  553. end;
  554. Stop = function(sound)
  555. if sound.IsPlaying then
  556. sound.Playing = false
  557. end
  558. if sound.TimePosition ~= 0 then
  559. sound.TimePosition = 0
  560. end
  561. end;
  562. }
  563.  
  564. do
  565. -- List of all active Looped sounds
  566. local playingLoopedSounds = {}
  567.  
  568. -- Last seen Enum.HumanoidStateType
  569. local activeState = nil
  570.  
  571. -- Verify and set that "sound" is in "playingLoopedSounds".
  572. function setSoundInPlayingLoopedSounds(sound)
  573. for i=1, #playingLoopedSounds do
  574. if playingLoopedSounds[i] == sound then
  575. return
  576. end
  577. end
  578. table.insert(playingLoopedSounds,sound)
  579. end
  580.  
  581. -- Stop all active looped sounds except parameter "except". If "except" is not passed, all looped sounds will be stopped.
  582. function stopPlayingLoopedSoundsExcept(except)
  583. for i=#playingLoopedSounds,1,-1 do
  584. if playingLoopedSounds[i] ~= except then
  585. Util.Pause(playingLoopedSounds[i])
  586. table.remove(playingLoopedSounds,i)
  587. end
  588. end
  589. end
  590.  
  591. -- Table of Enum.HumanoidStateType to handling function
  592. local stateUpdateHandler = {
  593. [Enum.HumanoidStateType.Dead] = function()
  594. stopPlayingLoopedSoundsExcept()
  595. local sound = Sounds[SFX.Died]
  596. Util.Play(sound)
  597. end;
  598.  
  599. [Enum.HumanoidStateType.RunningNoPhysics] = function()
  600. stateUpdated(Enum.HumanoidStateType.Running)
  601. end;
  602.  
  603. [Enum.HumanoidStateType.Running] = function()
  604. local sound = Sounds[SFX.Running]
  605. stopPlayingLoopedSoundsExcept(sound)
  606.  
  607. if Util.HorizontalSpeed(Head) > 0.5 then
  608. Util.Resume(sound)
  609. setSoundInPlayingLoopedSounds(sound)
  610. else
  611. stopPlayingLoopedSoundsExcept()
  612. end
  613. end;
  614.  
  615. [Enum.HumanoidStateType.Swimming] = function()
  616. if activeState ~= Enum.HumanoidStateType.Swimming and Util.VerticalSpeed(Head) > 0.1 then
  617. local splashSound = Sounds[SFX.Splash]
  618. splashSound.Volume = Util.Clamp(
  619. Util.YForLineGivenXAndTwoPts(
  620. Util.VerticalSpeed(Head),
  621. 100, 0.28,
  622. 350, 1),
  623. 0,1)
  624. Util.Play(splashSound)
  625. end
  626.  
  627. do
  628. local sound = Sounds[SFX.Swimming]
  629. stopPlayingLoopedSoundsExcept(sound)
  630. Util.Resume(sound)
  631. setSoundInPlayingLoopedSounds(sound)
  632. end
  633. end;
  634.  
  635. [Enum.HumanoidStateType.Climbing] = function()
  636. local sound = Sounds[SFX.Climbing]
  637. if Util.VerticalSpeed(Head) > 0.1 then
  638. Util.Resume(sound)
  639. stopPlayingLoopedSoundsExcept(sound)
  640. else
  641. stopPlayingLoopedSoundsExcept()
  642. end
  643. setSoundInPlayingLoopedSounds(sound)
  644. end;
  645.  
  646. [Enum.HumanoidStateType.Jumping] = function()
  647. if activeState == Enum.HumanoidStateType.Jumping then
  648. return
  649. end
  650. stopPlayingLoopedSoundsExcept()
  651. local sound = Sounds[SFX.Jumping]
  652. Util.Play(sound)
  653. end;
  654.  
  655. [Enum.HumanoidStateType.GettingUp] = function()
  656. stopPlayingLoopedSoundsExcept()
  657. local sound = Sounds[SFX.GettingUp]
  658. Util.Play(sound)
  659. end;
  660.  
  661. [Enum.HumanoidStateType.Freefall] = function()
  662. if activeState == Enum.HumanoidStateType.Freefall then
  663. return
  664. end
  665. local sound = Sounds[SFX.FreeFalling]
  666. sound.Volume = 0
  667. stopPlayingLoopedSoundsExcept()
  668. end;
  669.  
  670. [Enum.HumanoidStateType.FallingDown] = function()
  671. stopPlayingLoopedSoundsExcept()
  672. end;
  673.  
  674. [Enum.HumanoidStateType.Landed] = function()
  675. stopPlayingLoopedSoundsExcept()
  676. if Util.VerticalSpeed(Head) > 75 then
  677. local landingSound = Sounds[SFX.Landing]
  678. landingSound.Volume = Util.Clamp(
  679. Util.YForLineGivenXAndTwoPts(
  680. Util.VerticalSpeed(Head),
  681. 50, 0,
  682. 100, 1),
  683. 0,1)
  684. Util.Play(landingSound)
  685. end
  686. end;
  687.  
  688. [Enum.HumanoidStateType.Seated] = function()
  689. stopPlayingLoopedSoundsExcept()
  690. end;
  691. }
  692.  
  693. -- Handle state event fired or OnChange fired
  694. function stateUpdated(state)
  695. if stateUpdateHandler[state] ~= nil then
  696. stateUpdateHandler[state]()
  697. end
  698. activeState = state
  699. end
  700.  
  701. Humanoid.Died:connect( function() stateUpdated(Enum.HumanoidStateType.Dead) end)
  702. Humanoid.Running:connect( function() stateUpdated(Enum.HumanoidStateType.Running) end)
  703. Humanoid.Swimming:connect( function() stateUpdated(Enum.HumanoidStateType.Swimming) end)
  704. Humanoid.Climbing:connect( function() stateUpdated(Enum.HumanoidStateType.Climbing) end)
  705. Humanoid.Jumping:connect( function() stateUpdated(Enum.HumanoidStateType.Jumping) end)
  706. Humanoid.GettingUp:connect( function() stateUpdated(Enum.HumanoidStateType.GettingUp) end)
  707. Humanoid.FreeFalling:connect( function() stateUpdated(Enum.HumanoidStateType.Freefall) end)
  708. Humanoid.FallingDown:connect( function() stateUpdated(Enum.HumanoidStateType.FallingDown) end)
  709.  
  710. -- required for proper handling of Landed event
  711. Humanoid.StateChanged:connect(function(old, new)
  712. stateUpdated(new)
  713. end)
  714.  
  715.  
  716. function onUpdate(stepDeltaSeconds, tickSpeedSeconds)
  717. local stepScale = stepDeltaSeconds / tickSpeedSeconds
  718. do
  719. local sound = Sounds[SFX.FreeFalling]
  720. if activeState == Enum.HumanoidStateType.Freefall then
  721. if Head.Velocity.Y < 0 and Util.VerticalSpeed(Head) > 75 then
  722. Util.Resume(sound)
  723.  
  724. --Volume takes 1.1 seconds to go from volume 0 to 1
  725. local ANIMATION_LENGTH_SECONDS = 1.1
  726.  
  727. local normalizedIncrement = tickSpeedSeconds / ANIMATION_LENGTH_SECONDS
  728. sound.Volume = Util.Clamp(sound.Volume + normalizedIncrement * stepScale, 0, 1)
  729. else
  730. sound.Volume = 0
  731. end
  732. else
  733. Util.Pause(sound)
  734. end
  735. end
  736.  
  737. do
  738. local sound = Sounds[SFX.Running]
  739. if activeState == Enum.HumanoidStateType.Running then
  740. if Util.HorizontalSpeed(Head) < 0.5 then
  741. Util.Pause(sound)
  742. end
  743. end
  744. end
  745. end
  746.  
  747. local lastTick = tick()
  748. local TICK_SPEED_SECONDS = 0.25
  749. while true do
  750. onUpdate(tick() - lastTick,TICK_SPEED_SECONDS)
  751. lastTick = tick()
  752. wait(TICK_SPEED_SECONDS)
  753. end
  754. end
  755.  
  756. end))
  757. LocalScript29.Name = "Animate"
  758. LocalScript29.Parent = Model0
  759. table.insert(cors,sandbox(LocalScript29,function()
  760. function waitForChild(parent, childName)
  761. local child = parent:findFirstChild(childName)
  762. if child then return child end
  763. while true do
  764. child = parent.ChildAdded:wait()
  765. if child.Name==childName then return child end
  766. end
  767. end
  768.  
  769. local Figure = script.Parent
  770. local Torso = waitForChild(Figure, "Torso")
  771. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  772. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  773. local RightHip = waitForChild(Torso, "Right Hip")
  774. local LeftHip = waitForChild(Torso, "Left Hip")
  775. local Neck = waitForChild(Torso, "Neck")
  776. local Humanoid = waitForChild(Figure, "Humanoid")
  777. local pose = "Standing"
  778.  
  779. local currentAnim = ""
  780. local currentAnimInstance = nil
  781. local currentAnimTrack = nil
  782. local currentAnimKeyframeHandler = nil
  783. local currentAnimSpeed = 1.0
  784. local animTable = {}
  785. local animNames = {
  786. idle = {
  787. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  788. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  789. },
  790. walk = {
  791. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  792. },
  793. run = {
  794. { id = "run.xml", weight = 10 }
  795. },
  796. jump = {
  797. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  798. },
  799. fall = {
  800. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  801. },
  802. climb = {
  803. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  804. },
  805. sit = {
  806. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  807. },
  808. toolnone = {
  809. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  810. },
  811. toolslash = {
  812. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  813. -- { id = "slash.xml", weight = 10 }
  814. },
  815. toollunge = {
  816. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  817. },
  818. wave = {
  819. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  820. },
  821. point = {
  822. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  823. },
  824. dance1 = {
  825. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  826. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  827. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  828. },
  829. dance2 = {
  830. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  831. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  832. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  833. },
  834. dance3 = {
  835. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  836. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  837. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  838. },
  839. laugh = {
  840. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  841. },
  842. cheer = {
  843. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  844. },
  845. }
  846. local dances = {"dance1", "dance2", "dance3"}
  847.  
  848. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  849. local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  850.  
  851. function configureAnimationSet(name, fileList)
  852. if (animTable[name] ~= nil) then
  853. for _, connection in pairs(animTable[name].connections) do
  854. connection:disconnect()
  855. end
  856. end
  857. animTable[name] = {}
  858. animTable[name].count = 0
  859. animTable[name].totalWeight = 0
  860. animTable[name].connections = {}
  861.  
  862. -- check for config values
  863. local config = script:FindFirstChild(name)
  864. if (config ~= nil) then
  865. -- print("Loading anims " .. name)
  866. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  867. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  868. local idx = 1
  869. for _, childPart in pairs(config:GetChildren()) do
  870. if (childPart:IsA("Animation")) then
  871. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  872. animTable[name][idx] = {}
  873. animTable[name][idx].anim = childPart
  874. local weightObject = childPart:FindFirstChild("Weight")
  875. if (weightObject == nil) then
  876. animTable[name][idx].weight = 1
  877. else
  878. animTable[name][idx].weight = weightObject.Value
  879. end
  880. animTable[name].count = animTable[name].count + 1
  881. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  882. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  883. idx = idx + 1
  884. end
  885. end
  886. end
  887.  
  888. -- fallback to defaults
  889. if (animTable[name].count <= 0) then
  890. for idx, anim in pairs(fileList) do
  891. animTable[name][idx] = {}
  892. animTable[name][idx].anim = Instance.new("Animation")
  893. animTable[name][idx].anim.Name = name
  894. animTable[name][idx].anim.AnimationId = anim.id
  895. animTable[name][idx].weight = anim.weight
  896. animTable[name].count = animTable[name].count + 1
  897. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  898. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  899. end
  900. end
  901. end
  902.  
  903. -- Setup animation objects
  904. function scriptChildModified(child)
  905. local fileList = animNames[child.Name]
  906. if (fileList ~= nil) then
  907. configureAnimationSet(child.Name, fileList)
  908. end
  909. end
  910.  
  911. script.ChildAdded:connect(scriptChildModified)
  912. script.ChildRemoved:connect(scriptChildModified)
  913.  
  914.  
  915. for name, fileList in pairs(animNames) do
  916. configureAnimationSet(name, fileList)
  917. end
  918.  
  919. -- ANIMATION
  920.  
  921. -- declarations
  922. local toolAnim = "None"
  923. local toolAnimTime = 0
  924.  
  925. local jumpAnimTime = 0
  926. local jumpAnimDuration = 0.3
  927.  
  928. local toolTransitionTime = 0.1
  929. local fallTransitionTime = 0.3
  930. local jumpMaxLimbVelocity = 0.75
  931.  
  932. -- functions
  933.  
  934. function stopAllAnimations()
  935. local oldAnim = currentAnim
  936.  
  937. -- return to idle if finishing an emote
  938. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  939. oldAnim = "idle"
  940. end
  941.  
  942. currentAnim = ""
  943. currentAnimInstance = nil
  944. if (currentAnimKeyframeHandler ~= nil) then
  945. currentAnimKeyframeHandler:disconnect()
  946. end
  947.  
  948. if (currentAnimTrack ~= nil) then
  949. currentAnimTrack:Stop()
  950. currentAnimTrack:Destroy()
  951. currentAnimTrack = nil
  952. end
  953. return oldAnim
  954. end
  955.  
  956. function setAnimationSpeed(speed)
  957. if speed ~= currentAnimSpeed then
  958. currentAnimSpeed = speed
  959. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  960. end
  961. end
  962.  
  963. function keyFrameReachedFunc(frameName)
  964. if (frameName == "End") then
  965.  
  966. local repeatAnim = currentAnim
  967. -- return to idle if finishing an emote
  968. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  969. repeatAnim = "idle"
  970. end
  971.  
  972. local animSpeed = currentAnimSpeed
  973. playAnimation(repeatAnim, 0.0, Humanoid)
  974. setAnimationSpeed(animSpeed)
  975. end
  976. end
  977.  
  978. -- Preload animations
  979. function playAnimation(animName, transitionTime, humanoid)
  980.  
  981. local roll = math.random(1, animTable[animName].totalWeight)
  982. local origRoll = roll
  983. local idx = 1
  984. while (roll > animTable[animName][idx].weight) do
  985. roll = roll - animTable[animName][idx].weight
  986. idx = idx + 1
  987. end
  988. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  989. local anim = animTable[animName][idx].anim
  990.  
  991. -- switch animation
  992. if (anim ~= currentAnimInstance) then
  993.  
  994. if (currentAnimTrack ~= nil) then
  995. currentAnimTrack:Stop(transitionTime)
  996. currentAnimTrack:Destroy()
  997. end
  998.  
  999. currentAnimSpeed = 1.0
  1000.  
  1001. -- load it to the humanoid; get AnimationTrack
  1002. currentAnimTrack = humanoid:LoadAnimation(anim)
  1003.  
  1004. -- play the animation
  1005. currentAnimTrack:Play(transitionTime)
  1006. currentAnim = animName
  1007. currentAnimInstance = anim
  1008.  
  1009. -- set up keyframe name triggers
  1010. if (currentAnimKeyframeHandler ~= nil) then
  1011. currentAnimKeyframeHandler:disconnect()
  1012. end
  1013. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  1014.  
  1015. end
  1016.  
  1017. end
  1018.  
  1019. -------------------------------------------------------------------------------------------
  1020. -------------------------------------------------------------------------------------------
  1021.  
  1022. local toolAnimName = ""
  1023. local toolAnimTrack = nil
  1024. local toolAnimInstance = nil
  1025. local currentToolAnimKeyframeHandler = nil
  1026.  
  1027. function toolKeyFrameReachedFunc(frameName)
  1028. if (frameName == "End") then
  1029. -- print("Keyframe : ".. frameName)
  1030. playToolAnimation(toolAnimName, 0.0, Humanoid)
  1031. end
  1032. end
  1033.  
  1034.  
  1035. function playToolAnimation(animName, transitionTime, humanoid)
  1036.  
  1037. local roll = math.random(1, animTable[animName].totalWeight)
  1038. local origRoll = roll
  1039. local idx = 1
  1040. while (roll > animTable[animName][idx].weight) do
  1041. roll = roll - animTable[animName][idx].weight
  1042. idx = idx + 1
  1043. end
  1044. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  1045. local anim = animTable[animName][idx].anim
  1046.  
  1047. if (toolAnimInstance ~= anim) then
  1048.  
  1049. if (toolAnimTrack ~= nil) then
  1050. toolAnimTrack:Stop()
  1051. toolAnimTrack:Destroy()
  1052. transitionTime = 0
  1053. end
  1054.  
  1055. -- load it to the humanoid; get AnimationTrack
  1056. toolAnimTrack = humanoid:LoadAnimation(anim)
  1057.  
  1058. -- play the animation
  1059. toolAnimTrack:Play(transitionTime)
  1060. toolAnimName = animName
  1061. toolAnimInstance = anim
  1062.  
  1063. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  1064. end
  1065. end
  1066.  
  1067. function stopToolAnimations()
  1068. local oldAnim = toolAnimName
  1069.  
  1070. if (currentToolAnimKeyframeHandler ~= nil) then
  1071. currentToolAnimKeyframeHandler:disconnect()
  1072. end
  1073.  
  1074. toolAnimName = ""
  1075. toolAnimInstance = nil
  1076. if (toolAnimTrack ~= nil) then
  1077. toolAnimTrack:Stop()
  1078. toolAnimTrack:Destroy()
  1079. toolAnimTrack = nil
  1080. end
  1081.  
  1082.  
  1083. return oldAnim
  1084. end
  1085.  
  1086. -------------------------------------------------------------------------------------------
  1087. -------------------------------------------------------------------------------------------
  1088.  
  1089.  
  1090. function onRunning(speed)
  1091. if speed>0.01 then
  1092. playAnimation("walk", 0.1, Humanoid)
  1093. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  1094. setAnimationSpeed(speed / 14.5)
  1095. end
  1096. pose = "Running"
  1097. else
  1098. if emoteNames[currentAnim] == nil then
  1099. playAnimation("idle", 0.1, Humanoid)
  1100. pose = "Standing"
  1101. end
  1102. end
  1103. end
  1104.  
  1105. function onDied()
  1106. pose = "Dead"
  1107. end
  1108.  
  1109. function onJumping()
  1110. playAnimation("jump", 0.1, Humanoid)
  1111. jumpAnimTime = jumpAnimDuration
  1112. pose = "Jumping"
  1113. end
  1114.  
  1115. function onClimbing(speed)
  1116. playAnimation("climb", 0.1, Humanoid)
  1117. setAnimationSpeed(speed / 12.0)
  1118. pose = "Climbing"
  1119. end
  1120.  
  1121. function onGettingUp()
  1122. pose = "GettingUp"
  1123. end
  1124.  
  1125. function onFreeFall()
  1126. if (jumpAnimTime <= 0) then
  1127. playAnimation("fall", fallTransitionTime, Humanoid)
  1128. end
  1129. pose = "FreeFall"
  1130. end
  1131.  
  1132. function onFallingDown()
  1133. pose = "FallingDown"
  1134. end
  1135.  
  1136. function onSeated()
  1137. pose = "Seated"
  1138. end
  1139.  
  1140. function onPlatformStanding()
  1141. pose = "PlatformStanding"
  1142. end
  1143.  
  1144. function onSwimming(speed)
  1145. if speed>0 then
  1146. pose = "Running"
  1147. else
  1148. pose = "Standing"
  1149. end
  1150. end
  1151.  
  1152. function getTool()
  1153. for _, kid in ipairs(Figure:GetChildren()) do
  1154. if kid.className == "Tool" then return kid end
  1155. end
  1156. return nil
  1157. end
  1158.  
  1159. function getToolAnim(tool)
  1160. for _, c in ipairs(tool:GetChildren()) do
  1161. if c.Name == "toolanim" and c.className == "StringValue" then
  1162. return c
  1163. end
  1164. end
  1165. return nil
  1166. end
  1167.  
  1168. function animateTool()
  1169.  
  1170. if (toolAnim == "None") then
  1171. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  1172. return
  1173. end
  1174.  
  1175. if (toolAnim == "Slash") then
  1176. playToolAnimation("toolslash", 0, Humanoid)
  1177. return
  1178. end
  1179.  
  1180. if (toolAnim == "Lunge") then
  1181. playToolAnimation("toollunge", 0, Humanoid)
  1182. return
  1183. end
  1184. end
  1185.  
  1186. function moveSit()
  1187. RightShoulder.MaxVelocity = 0.15
  1188. LeftShoulder.MaxVelocity = 0.15
  1189. RightShoulder:SetDesiredAngle(3.14 /2)
  1190. LeftShoulder:SetDesiredAngle(-3.14 /2)
  1191. RightHip:SetDesiredAngle(3.14 /2)
  1192. LeftHip:SetDesiredAngle(-3.14 /2)
  1193. end
  1194.  
  1195. local lastTick = 0
  1196.  
  1197. function move(time)
  1198. local amplitude = 1
  1199. local frequency = 1
  1200. local deltaTime = time - lastTick
  1201. lastTick = time
  1202.  
  1203. local climbFudge = 0
  1204. local setAngles = false
  1205.  
  1206. if (jumpAnimTime > 0) then
  1207. jumpAnimTime = jumpAnimTime - deltaTime
  1208. end
  1209.  
  1210. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  1211. playAnimation("fall", fallTransitionTime, Humanoid)
  1212. elseif (pose == "Seated") then
  1213. playAnimation("sit", 0.5, Humanoid)
  1214. return
  1215. elseif (pose == "Running") then
  1216. playAnimation("walk", 0.1, Humanoid)
  1217. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  1218. -- print("Wha " .. pose)
  1219. stopAllAnimations()
  1220. amplitude = 0.1
  1221. frequency = 1
  1222. setAngles = true
  1223. end
  1224.  
  1225. if (setAngles) then
  1226. desiredAngle = amplitude * math.sin(time * frequency)
  1227.  
  1228. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  1229. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  1230. RightHip:SetDesiredAngle(-desiredAngle)
  1231. LeftHip:SetDesiredAngle(-desiredAngle)
  1232. end
  1233.  
  1234. -- Tool Animation handling
  1235. local tool = getTool()
  1236. if tool and tool:FindFirstChild("Handle") then
  1237.  
  1238. animStringValueObject = getToolAnim(tool)
  1239.  
  1240. if animStringValueObject then
  1241. toolAnim = animStringValueObject.Value
  1242. -- message recieved, delete StringValue
  1243. animStringValueObject.Parent = nil
  1244. toolAnimTime = time + .3
  1245. end
  1246.  
  1247. if time > toolAnimTime then
  1248. toolAnimTime = 0
  1249. toolAnim = "None"
  1250. end
  1251.  
  1252. animateTool()
  1253. else
  1254. stopToolAnimations()
  1255. toolAnim = "None"
  1256. toolAnimInstance = nil
  1257. toolAnimTime = 0
  1258. end
  1259. end
  1260.  
  1261. -- connect events
  1262. Humanoid.Died:connect(onDied)
  1263. Humanoid.Running:connect(onRunning)
  1264. Humanoid.Jumping:connect(onJumping)
  1265. Humanoid.Climbing:connect(onClimbing)
  1266. Humanoid.GettingUp:connect(onGettingUp)
  1267. Humanoid.FreeFalling:connect(onFreeFall)
  1268. Humanoid.FallingDown:connect(onFallingDown)
  1269. Humanoid.Seated:connect(onSeated)
  1270. Humanoid.PlatformStanding:connect(onPlatformStanding)
  1271. Humanoid.Swimming:connect(onSwimming)
  1272.  
  1273. -- setup emote chat hook
  1274. game.Players.LocalPlayer.Chatted:connect(function(msg)
  1275. local emote = ""
  1276. if msg == "/e dance" then
  1277. emote = dances[math.random(1, #dances)]
  1278. elseif (string.sub(msg, 1, 3) == "/e ") then
  1279. emote = string.sub(msg, 4)
  1280. elseif (string.sub(msg, 1, 7) == "/emote ") then
  1281. emote = string.sub(msg, 8)
  1282. end
  1283.  
  1284. if (pose == "Standing" and emoteNames[emote] ~= nil) then
  1285. playAnimation(emote, 0.1, Humanoid)
  1286. end
  1287.  
  1288. end)
  1289.  
  1290.  
  1291. -- main program
  1292.  
  1293. local runService = game:service("RunService");
  1294.  
  1295. -- initialize to idle
  1296. playAnimation("idle", 0.1, Humanoid)
  1297. pose = "Standing"
  1298.  
  1299. while Figure.Parent~=nil do
  1300. local _, time = wait(0.1)
  1301. move(time)
  1302. end
  1303.  
  1304.  
  1305.  
  1306. end))
  1307. StringValue30.Name = "idle"
  1308. StringValue30.Parent = LocalScript29
  1309. Animation31.Name = "Animation1"
  1310. Animation31.Parent = StringValue30
  1311. Animation31.AnimationId = "http://www.roblox.com/asset/?id=180435571"
  1312. NumberValue32.Name = "Weight"
  1313. NumberValue32.Parent = Animation31
  1314. NumberValue32.Value = 9
  1315. Animation33.Name = "Animation2"
  1316. Animation33.Parent = StringValue30
  1317. Animation33.AnimationId = "http://www.roblox.com/asset/?id=180435792"
  1318. NumberValue34.Name = "Weight"
  1319. NumberValue34.Parent = Animation33
  1320. NumberValue34.Value = 1
  1321. StringValue35.Name = "walk"
  1322. StringValue35.Parent = LocalScript29
  1323. Animation36.Name = "WalkAnim"
  1324. Animation36.Parent = StringValue35
  1325. Animation36.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  1326. StringValue37.Name = "run"
  1327. StringValue37.Parent = LocalScript29
  1328. Animation38.Name = "RunAnim"
  1329. Animation38.Parent = StringValue37
  1330. Animation38.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  1331. StringValue39.Name = "jump"
  1332. StringValue39.Parent = LocalScript29
  1333. Animation40.Name = "JumpAnim"
  1334. Animation40.Parent = StringValue39
  1335. Animation40.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  1336. StringValue41.Name = "climb"
  1337. StringValue41.Parent = LocalScript29
  1338. Animation42.Name = "ClimbAnim"
  1339. Animation42.Parent = StringValue41
  1340. Animation42.AnimationId = "http://www.roblox.com/asset/?id=180436334"
  1341. StringValue43.Name = "toolnone"
  1342. StringValue43.Parent = LocalScript29
  1343. Animation44.Name = "ToolNoneAnim"
  1344. Animation44.Parent = StringValue43
  1345. Animation44.AnimationId = "http://www.roblox.com/asset/?id=182393478"
  1346. StringValue45.Name = "fall"
  1347. StringValue45.Parent = LocalScript29
  1348. Animation46.Name = "FallAnim"
  1349. Animation46.Parent = StringValue45
  1350. Animation46.AnimationId = "http://www.roblox.com/asset/?id=180436148"
  1351. StringValue47.Name = "sit"
  1352. StringValue47.Parent = LocalScript29
  1353. Animation48.Name = "SitAnim"
  1354. Animation48.Parent = StringValue47
  1355. Animation48.AnimationId = "http://www.roblox.com/asset/?id=178130996"
  1356. Script49.Name = "Health"
  1357. Script49.Parent = Model0
  1358. table.insert(cors,sandbox(Script49,function()
  1359. --Responsible for regening a player's humanoid's health
  1360.  
  1361. -- declarations
  1362. local Figure = script.Parent
  1363. local Head = Figure:WaitForChild("Head")
  1364. local Humanoid = Figure:WaitForChild("Humanoid")
  1365. local regening = false
  1366.  
  1367. -- regeneration
  1368. function regenHealth()
  1369. if regening then return end
  1370. regening = true
  1371.  
  1372. while Humanoid.Health < Humanoid.MaxHealth do
  1373. local s = wait(1)
  1374. local health = Humanoid.Health
  1375. if health > 0 and health < Humanoid.MaxHealth then
  1376. local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
  1377. health = health + newHealthDelta
  1378. Humanoid.Health = math.min(health,Humanoid.MaxHealth)
  1379. end
  1380. end
  1381.  
  1382. if Humanoid.Health > Humanoid.MaxHealth then
  1383. Humanoid.Health = Humanoid.MaxHealth
  1384. end
  1385.  
  1386. regening = false
  1387. end
  1388.  
  1389. Humanoid.HealthChanged:connect(regenHealth)
  1390.  
  1391. end))
  1392. BodyColors50.Parent = Model0
  1393. BodyColors50.HeadColor = BrickColor.new("Mid gray")
  1394. BodyColors50.HeadColor3 = Color3.new(0.803922, 0.803922, 0.803922)
  1395. BodyColors50.LeftArmColor = BrickColor.new("Mid gray")
  1396. BodyColors50.LeftArmColor3 = Color3.new(0.803922, 0.803922, 0.803922)
  1397. BodyColors50.LeftLegColor = BrickColor.new("Pastel light blue")
  1398. BodyColors50.LeftLegColor3 = Color3.new(0.686275, 0.866667, 1)
  1399. BodyColors50.RightArmColor = BrickColor.new("Mid gray")
  1400. BodyColors50.RightArmColor3 = Color3.new(0.803922, 0.803922, 0.803922)
  1401. BodyColors50.RightLegColor = BrickColor.new("Pastel light blue")
  1402. BodyColors50.RightLegColor3 = Color3.new(0.686275, 0.866667, 1)
  1403. BodyColors50.TorsoColor = BrickColor.new("Bright green")
  1404. BodyColors50.TorsoColor3 = Color3.new(0.294118, 0.592157, 0.294118)
  1405. for i,v in pairs(mas:GetChildren()) do
  1406. v.Parent = owner.Character
  1407. pcall(function() v:MakeJoints() end)
  1408. end
  1409. mas:Destroy()
  1410. for i,v in pairs(cors) do
  1411. spawn(function()
  1412. pcall(v)
  1413. end)
  1414. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement