Advertisement
Blueisim

AERX ANTIBAN WIP

Sep 4th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.44 KB | None | 0 0
  1. TaskScheduler = {};
  2. PyramidCharacter = {};
  3. local RbxUtility = LoadLibrary("RbxUtility")
  4. local InsertService = game:service'InsertService'
  5. local RunService = game:service'RunService'
  6. local rbx_Wait = wait
  7. local rbx_ypcall = ypcall
  8. local threads, swapThreads = {}, {}
  9. local function StartCoroutine(func, delay, ...)
  10. if delay > 0 then
  11. rbx_Wait(delay)
  12. end
  13. local success, message = rbx_ypcall(func, ...)
  14. if not success then
  15. print("Error in a TaskScheduler coroutine: "..message)
  16. end
  17. end
  18. function TaskScheduler.GetCurrentTime()
  19. return currentTime
  20. end
  21.  
  22.  
  23.  
  24. function TaskScheduler.MainLoop(stepTime)
  25. currentTime = currentTime + stepTime
  26. threads, swapThreads = swapThreads, threads
  27. local threshold = -0.5 * stepTime
  28. for thread, resumeTime in pairs(swapThreads) do
  29. local remainingTime = currentTime - resumeTime
  30. if remainingTime >= threshold then
  31. swapThreads[thread] = nil
  32. local success, message = coroutine.resume(thread, remainingTime, currentTime)
  33. if not success then
  34. print("Error in a TaskScheduler custom thread: "..message)
  35. end
  36. end
  37. end
  38. threads, swapThreads = swapThreads, threads
  39. for thread, resumeTime in pairs(swapThreads) do
  40. threads[thread], swapThreads[thread] = resumeTime, nil
  41. end
  42. end
  43. -- TODO: add stack trace info to scheduling functions?
  44. function TaskScheduler.Schedule(t, f, ...)
  45. coroutine.resume(coroutine.create(StartCoroutine), f, t, ...)
  46. end
  47. function TaskScheduler.Start(f, ...)
  48. coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
  49. end
  50. function TaskScheduler.ScheduleCustomThread(t, f)
  51. threads[coroutine.create(f)] = currentTime + t
  52. end
  53. function TaskScheduler.Wait(duration)
  54. duration = tonumber(duration) or 0
  55. threads[coroutine.running()] = currentTime + duration
  56. local remainingTime, currentTime = coroutine.yield()
  57. return remainingTime + duration, currentTime
  58. end
  59. local Players=game.Players
  60. local success, player = Players.LocalPlayer
  61. if success and player then
  62. RunService.RenderStepped:connect(function()
  63. TaskScheduler.MainLoop(1 / 60)
  64. end)
  65. else
  66. RunService.Stepped:connect(function()
  67. TaskScheduler.MainLoop(1 / 30)
  68. end)
  69. end
  70. function TaskScheduler.Start(f, ...)
  71. coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
  72. end
  73. local Camera = workspace.CurrentCamera or nil
  74. CharacterAppearance = {};
  75.  
  76. CharacterAppearance.defaultAppearanceId = 2
  77. CharacterAppearance.stock = {}
  78. function CharacterAppearance.Create(properties)
  79. local id = properties.Id
  80. local bodyColors = Instance.new("BodyColors")
  81. bodyColors.HeadColor = properties.HeadColor
  82. bodyColors.TorsoColor = properties.TorsoColor
  83. bodyColors.RightArmColor = properties.RightArmColor
  84. bodyColors.LeftArmColor = properties.LeftArmColor
  85. bodyColors.RightLegColor = properties.RightLegColor
  86. bodyColors.LeftLegColor = properties.LeftLegColor
  87. local characterObjects = {bodyColors}
  88. local headObjects = {}
  89. local data = {
  90. characterObjects = characterObjects,
  91. headObjects = headObjects,
  92. tshirt = properties.TShirt
  93. }
  94. for _, assetId in ipairs(properties.CharacterAssets) do
  95. TaskScheduler.Start(CharacterAppearance.LoadAsset, characterObjects, assetId)
  96. end
  97. for _, assetId in ipairs(properties.HeadAssets) do
  98. TaskScheduler.Start(CharacterAppearance.LoadAsset, headObjects, assetId)
  99. end
  100. CharacterAppearance.stock[id] = data
  101. end
  102. function CharacterAppearance.GetDefaultAppearance()
  103. return CharacterAppearance.stock[CharacterAppearance.defaultAppearanceId]
  104. end
  105. function CharacterAppearance.LoadAsset(objects, assetId)
  106. local asset = InsertService:LoadAsset(assetId)
  107. for _, child in ipairs(asset:GetChildren()) do
  108. child.Archivable = true
  109. table.insert(objects, child:Clone())
  110. end
  111. end
  112. CharacterAppearance.Create {
  113. Id = 1,
  114. HeadColor = BrickColor.new("Institutional white"),
  115. TorsoColor = BrickColor.new("Institutional white"),
  116. RightArmColor = BrickColor.new("Institutional white"),
  117. LeftArmColor = BrickColor.new("Institutional white"),
  118. RightLegColor = BrickColor.new("Institutional white"),
  119. LeftLegColor = BrickColor.new("Institutional white"),
  120. CharacterAssets = {
  121. 90825058, 90825211,
  122. 27112056, 27112052,
  123. 27112039, 27112025,
  124. 27112068, 38322996
  125. },
  126. HeadAssets = {
  127. 20722130,
  128. 8330576
  129. }
  130. }
  131. CharacterAppearance.Create {
  132. Id = 2,
  133. HeadColor = BrickColor.new("Institutional white"),
  134. TorsoColor = BrickColor.new("Institutional white"),
  135. RightArmColor = BrickColor.new("Institutional white"),
  136. LeftArmColor = BrickColor.new("Institutional white"),
  137. RightLegColor = BrickColor.new("Institutional white"),
  138. LeftLegColor = BrickColor.new("Institutional white"),
  139. CharacterAssets = {
  140. 90825058, 90825211,
  141. 11748356, 1029025,
  142. 1235488, 27112056,
  143. 27112052, 27112039,
  144. 27112025, 27112068
  145. },
  146. HeadAssets = {
  147. 20722130
  148. }
  149. }
  150. CharacterAppearance.Create {
  151. Id = 3,
  152. HeadColor = BrickColor.new("Pastel brown"),
  153. TorsoColor = BrickColor.new("Pastel brown"),
  154. RightArmColor = BrickColor.new("Pastel brown"),
  155. LeftArmColor = BrickColor.new("Pastel brown"),
  156. RightLegColor = BrickColor.new("White"),
  157. LeftLegColor = BrickColor.new("White"),
  158. CharacterAssets = {
  159. 134289125, 48474356,
  160. 100339040, 46302558,
  161. 153955895
  162. },
  163. HeadAssets = {},
  164. TShirt = "rbxassetid://148856353"
  165. }
  166. CharacterAppearance.Create {
  167. Id = 4,
  168. HeadColor = BrickColor.new("Pastel brown"),
  169. TorsoColor = BrickColor.new("Pastel brown"),
  170. RightArmColor = BrickColor.new("Pastel brown"),
  171. LeftArmColor = BrickColor.new("Pastel brown"),
  172. RightLegColor = BrickColor.new("White"),
  173. LeftLegColor = BrickColor.new("White"),
  174. CharacterAssets = {
  175. 129458426, 96678344, 184489190
  176. },
  177. HeadAssets = {},
  178. TShirt = "rbxassetid://160146697"
  179. }
  180. function CharacterAppearance.GetDefaultAppearance()
  181. return CharacterAppearance.stock[CharacterAppearance.defaultAppearanceId]
  182. end
  183. PlayerControl = {};
  184. PlayerControl.fly_acceleration = 10
  185. PlayerControl.fly_basespeed = 250
  186. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  187. PlayerControl.featherfallEnabled = true
  188. PlayerControl.pushable = false
  189. PlayerControl.rolling = false
  190. PlayerControl.rollingAngle = 0
  191. PlayerControl.rollingOffset = 0
  192. PlayerControl.rollingMaxOffset = 3
  193. PlayerControl.rollingSpeed = 1 / 50
  194. PlayerControl.characterEnabled = false
  195. PlayerControl.characterMode = "normal"
  196. local character = nil
  197. local flying, flyingMomentum, flyingTilt = false, Vector3.new(), 0
  198. local pose, regeneratingHealth, jumpDebounce = "Standing", false, false
  199. -- TODO: make local variables public
  200. local model, bodyColors, leftArmMesh, leftLegMesh, rightArmMesh, rightLegMesh, torsoMesh, wildcardHat, wildcardHandle, wildcardMesh, pants, shirt, humanoid,
  201.  
  202. head, leftArm, leftLeg, rightArm, rightLeg, torso, rootPart, rootJoint, face, soundFreeFalling, soundGettingUp, soundRunning, leftHip, leftShoulder,
  203.  
  204. rightHip, rightShoulder, neck, wildcardWeld, feetPart, feetWeld, feetTouchInterest, bodyGyro, bodyVelocity, headMesh, torsoLight
  205. local AnimateCharacter
  206. local UserInterface = game:service'UserInputService'
  207. local chatBubbles = {}
  208. local chatCharacterLimit = 240
  209. function PlayerControl.CreateCharacter()
  210. local characterMode = PlayerControl.characterMode
  211. if characterMode == "normal" then
  212. if not PlayerControl.characterEnabled then
  213. return
  214. end
  215. local appearance = CharacterAppearance.GetDefaultAppearance()
  216. local active = true
  217. local torsoCFrame = (torso and torso.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  218. if torsoCFrame.p.Y < -450 then
  219. torsoCFrame = CFrame.new(0, 10, 0)
  220. end
  221. local rootPartCFrame = (rootPart and rootPart.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  222. if rootPartCFrame.p.Y < -450 then
  223. rootPartCFrame = CFrame.new(0, 10, 0)
  224. end
  225. local cameraCFrame = Camera.CoordinateFrame
  226. local connections = {}
  227. local feetTouching = {}
  228. local previousWalkSpeed = 0
  229. local prevLeftHip, prevLeftShoulder, prevRightHip, prevRightShoulder = leftHip, leftShoulder, rightHip, rightShoulder
  230. model = Instance.new("Model")
  231. humanoid = Instance.new("Humanoid", model)
  232. head = Instance.new("Part", model)
  233. leftArm = Instance.new("Part", model)
  234. leftLeg = Instance.new("Part", model)
  235. rightArm = Instance.new("Part", model)
  236. rightLeg = Instance.new("Part", model)
  237. torso = Instance.new("Part", model)
  238. rootPart = Instance.new("Part", model)
  239. soundFallingDown = Instance.new("Sound", head)
  240. soundFreeFalling = Instance.new("Sound", head)
  241. soundGettingUp = Instance.new("Sound", head)
  242. soundJumping = Instance.new("Sound", head)
  243. soundRunning = Instance.new("Sound", head)
  244. leftHip = Instance.new("Motor", torso)
  245. leftShoulder = Instance.new("Motor", torso)
  246. rightHip = Instance.new("Motor", torso)
  247. rightShoulder = Instance.new("Motor", torso)
  248. neck = Instance.new("Motor", torso)
  249. rootJoint = Instance.new("Motor", rootPart)
  250. feetPart = Instance.new("Part", model)
  251. feetWeld = Instance.new("Weld", torso)
  252. bodyGyro = Instance.new("BodyGyro", rootPart)
  253. bodyVelocity = Instance.new("BodyVelocity", rootPart)
  254. model.Archivable = false
  255. local user_name=game.Players.LocalPlayer.Name
  256. local Player=game.Players.LocalPlayer
  257. model.Name = user_name or Player.Name
  258. model.PrimaryPart = head
  259. humanoid.LeftLeg = leftLeg
  260. humanoid.RightLeg = rightLeg
  261. humanoid.Torso = rootPart
  262. head.CFrame = torsoCFrame * CFrame.new(0, 1.5, 0)
  263. head.FormFactor = "Symmetric"
  264. head.Locked = true
  265. head.Name = "Head"
  266. head.Size = Vector3.new(2, 1, 1)
  267. head.TopSurface = "Smooth"
  268. leftArm.CanCollide = false
  269. leftArm.CFrame = torsoCFrame * CFrame.new(-1.5, 0, 0)
  270. leftArm.FormFactor = "Symmetric"
  271. leftArm.Locked = true
  272. leftArm.Name = "Left Arm"
  273. leftArm.Size = Vector3.new(1, 2, 1)
  274. leftLeg.BottomSurface = "Smooth"
  275. leftLeg.CanCollide = false
  276. leftLeg.CFrame = torsoCFrame * CFrame.new(-0.5, -2, 0)
  277. leftLeg.FormFactor = "Symmetric"
  278. leftLeg.Locked = true
  279. leftLeg.Name = "Left Leg"
  280. leftLeg.Size = Vector3.new(1, 2, 1)
  281. leftLeg.TopSurface = "Smooth"
  282. rightArm.CanCollide = false
  283. rightArm.CFrame = torsoCFrame * CFrame.new(1.5, 0, 0)
  284. rightArm.FormFactor = "Symmetric"
  285. rightArm.Locked = true
  286. rightArm.Name = "Right Arm"
  287. rightArm.Size = Vector3.new(1, 2, 1)
  288. rightLeg.BottomSurface = "Smooth"
  289. rightLeg.CanCollide = false
  290. rightLeg.CFrame = torsoCFrame * CFrame.new(0.5, -2, 0)
  291. rightLeg.FormFactor = "Symmetric"
  292. rightLeg.Locked = true
  293. rightLeg.Name = "Right Leg"
  294. rightLeg.Size = Vector3.new(1, 2, 1)
  295. rightLeg.TopSurface = "Smooth"
  296. torso.CFrame = torsoCFrame
  297. torso.FormFactor = "Symmetric"
  298. torso.LeftSurface = "Weld"
  299. torso.Locked = true
  300. torso.RightSurface = "Weld"
  301. torso.Name = "Torso"
  302. torso.Size = Vector3.new(2, 2, 1)
  303. rootPart.BottomSurface = "Smooth"
  304. rootPart.BrickColor = BrickColor.Blue()
  305. rootPart.CFrame = rootPartCFrame
  306. rootPart.FormFactor = "Symmetric"
  307. rootPart.LeftSurface = "Weld"
  308. rootPart.Locked = true
  309. rootPart.RightSurface = "Weld"
  310. rootPart.Name = "HumanoidRootPart"
  311. rootPart.Size = Vector3.new(2, 2, 1)
  312. rootPart.TopSurface = "Smooth"
  313. rootPart.Transparency = 1
  314. soundFreeFalling.Archivable = false
  315. soundFreeFalling.SoundId = "rbxasset://sounds/swoosh.wav"
  316. soundGettingUp.Archivable = false
  317. soundGettingUp.SoundId = "rbxasset://sounds/hit.wav"
  318. soundRunning.Archivable = false
  319. soundRunning.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
  320. soundRunning.Looped = true
  321. leftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  322. leftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  323. leftHip.MaxVelocity = 0.1
  324. leftHip.Name = "Left Hip"
  325. leftHip.Part0 = torso
  326. leftHip.Part1 = leftLeg
  327. leftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  328. leftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  329. leftShoulder.MaxVelocity = 0.15
  330. leftShoulder.Name = "Left Shoulder"
  331. leftShoulder.Part0 = torso
  332. leftShoulder.Part1 = leftArm
  333. rightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  334. rightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  335. rightHip.MaxVelocity = 0.1
  336. rightHip.Name = "Right Hip"
  337. rightHip.Part0 = torso
  338. rightHip.Part1 = rightLeg
  339. rightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  340. rightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  341. rightShoulder.MaxVelocity = 0.15
  342. rightShoulder.Name = "Right Shoulder"
  343. rightShoulder.Part0 = torso
  344. rightShoulder.Part1 = rightArm
  345. if prevLeftHip then
  346. leftHip.CurrentAngle = prevLeftHip.CurrentAngle
  347. leftHip.DesiredAngle = prevLeftHip.DesiredAngle
  348. end
  349. if prevLeftShoulder then
  350. leftShoulder.CurrentAngle = prevLeftShoulder.CurrentAngle
  351. leftShoulder.DesiredAngle = prevLeftShoulder.DesiredAngle
  352. end
  353. if prevRightHip then
  354. rightHip.CurrentAngle = prevRightHip.CurrentAngle
  355. rightHip.DesiredAngle = prevRightHip.DesiredAngle
  356. end
  357. if prevRightShoulder then
  358. rightShoulder.CurrentAngle = prevRightShoulder.CurrentAngle
  359. rightShoulder.DesiredAngle = prevRightShoulder.DesiredAngle
  360. end
  361. neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  362. neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  363. neck.Name = "Neck"
  364. neck.Part0 = torso
  365. neck.Part1 = head
  366. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  367. rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  368. rootJoint.Name = "RootJoint"
  369. rootJoint.Part0 = rootPart
  370. rootJoint.Part1 = torso
  371. feetPart.BottomSurface = "Smooth"
  372. feetPart.CanCollide = false
  373. feetPart.CFrame = torsoCFrame * CFrame.new(0, -3.1, 0)
  374. feetPart.FormFactor = "Custom"
  375. feetPart.Locked = true
  376. feetPart.Name = "Platform"
  377. feetPart.Size = Vector3.new(1.8, 0.2, 0.8)
  378. feetPart.TopSurface = "Smooth"
  379. feetPart.Transparency = 1
  380. feetWeld.C0 = CFrame.new(0, -3, 0)
  381. feetWeld.C1 = CFrame.new(0, 0.1, 0)
  382. feetWeld.Name = "PlatformWeld"
  383. feetWeld.Part0 = torso
  384. feetWeld.Part1 = feetPart
  385. table.insert(connections, feetPart.Touched:connect(function(hit)
  386. feetTouching[hit] = true
  387. end))
  388. table.insert(connections, feetPart.TouchEnded:connect(function(hit)
  389. feetTouching[hit] = nil
  390. end))
  391. feetTouchInterest = feetPart:FindFirstChild("TouchInterest")
  392. bodyGyro.D = 3250
  393. bodyGyro.P = 400000
  394. bodyGyro.maxTorque = Vector3.new(1000000000, 0, 1000000000)
  395. bodyVelocity.P = 5000
  396. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  397. bodyVelocity.velocity = Vector3.new(0, 0, 0)
  398. torsoLight = Instance.new("PointLight", torso)
  399. torsoLight.Brightness = 0.4
  400. torsoLight.Color = Color3.new(1, 1, 1)
  401. torsoLight.Range = 16
  402. torsoLight.Shadows = true
  403. local ff1, ff2, ff3, ff4, ff5, ff6, ff7, ff8, ff9 = Instance.new("ForceField", head), Instance.new("ForceField", leftArm), Instance.new("ForceField", leftLeg), Instance.new("ForceField", rightArm), Instance.new("ForceField", rightLeg), Instance.new("ForceField", torso), Instance.new("ForceField", wildcardHandle), Instance.new("ForceField", feetPart), Instance.new("ForceField", rootPart)
  404. local forcefields = {[ff1] = head, [ff2] = leftArm, [ff3] = leftLeg, [ff4] = rightArm, [ff5] = rightLeg, [ff6] = torso, [ff7] = wildcardHandle, [ff8] = feetPart, [ff9] = rootPart}
  405. local objects = {[humanoid] = true, [head] = true, [leftArm] = true, [leftLeg] = true, [rightArm] = true, [rightLeg] = true, [torso] = true, [rootPart] = true, [rootJoint] = true, [soundFreeFalling] = true, [soundGettingUp] = true, [soundRunning] = true, [leftHip] = true, [leftShoulder] = true, [rightHip] = true, [rightShoulder] = true, [neck] = true, [feetPart] = true, [feetWeld] = true, [feetTouchInterest] = true, [bodyGyro] = true, [bodyVelocity] = true, [ff1] = true, [ff2] = true, [ff3] = true, [ff4] = true, [ff5] = true, [ff6] = true, [ff7] = true, [ff8] = true, [ff9] = true}
  406. local tshirtUrl = appearance.tshirt
  407. if tshirtUrl then
  408. local tshirt = Instance.new("Decal", torso)
  409. tshirt.Name = "roblox"
  410. tshirt.Texture = tshirtUrl
  411. objects[tshirt] = true
  412. end
  413. for _, template in ipairs(appearance.characterObjects) do
  414. local object = template:Clone()
  415. local newObjects = {object}
  416. for _, object in ipairs(newObjects) do
  417. objects[object] = true
  418. for _, child in ipairs(object:GetChildren()) do
  419. table.insert(newObjects, child)
  420. end
  421. end
  422. if object:IsA("BodyColors") then
  423. head.BrickColor = object.HeadColor
  424. leftArm.BrickColor = object.LeftArmColor
  425. leftLeg.BrickColor = object.LeftLegColor
  426. rightArm.BrickColor = object.RightArmColor
  427. rightLeg.BrickColor = object.RightLegColor
  428. torso.BrickColor = object.TorsoColor
  429. elseif object:IsA("Hat") then
  430. local handle = object:FindFirstChild("Handle")
  431. if handle and handle:IsA("BasePart") then
  432. local weld = Instance.new("Weld", head)
  433. weld.C0 = CFrame.new(0, 0.5, 0)
  434. local attachmentPos = object.AttachmentPos
  435. local attachmentRight = object.AttachmentRight
  436. local attachmentUp = object.AttachmentUp
  437. local attachmentForward = object.AttachmentForward
  438. weld.C1 = CFrame.new(attachmentPos.X, attachmentPos.Y, attachmentPos.Z,
  439. attachmentRight.X, attachmentUp.X, -attachmentForward.X,
  440. attachmentRight.Y, attachmentUp.Y, -attachmentForward.Y,
  441. attachmentRight.Z, attachmentUp.Z, -attachmentForward.Z)
  442. weld.Name = "HeadWeld"
  443. weld.Part0 = head
  444. weld.Part1 = handle
  445. handle.Parent = model
  446. local antiGravity = Instance.new("BodyForce", handle)
  447. antiGravity.force = Vector3.new(0, handle:GetMass() * 196.2, 0)
  448. objects[object] = false
  449. object.Parent = nil
  450. objects[weld] = true
  451. end
  452. end
  453. object.Parent = model
  454. end
  455. local facePresent = false
  456. local headMeshPresent = false
  457. for _, template in ipairs(appearance.headObjects) do
  458. local object = template:Clone()
  459. local newObjects = {object}
  460. for _, object in ipairs(newObjects) do
  461. objects[object] = true
  462. for _, child in ipairs(object:GetChildren()) do
  463. table.insert(newObjects, child)
  464. end
  465. end
  466. if object:IsA("DataModelMesh") then
  467. headMeshPresent = true
  468. elseif object:IsA("Decal") then
  469. facePresent = true
  470. end
  471. object.Parent = head
  472. end
  473. if not facePresent then
  474. local face = Instance.new("Decal", head)
  475. face.Texture = "rbxasset://textures/face.png"
  476. objects[face] = true
  477. end
  478. if not headMeshPresent then
  479. local headMesh = Instance.new("SpecialMesh", head)
  480. headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  481. objects[headMesh] = true
  482. end
  483. table.insert(connections, model.DescendantAdded:connect(function(object)
  484. local success, is_localscript = pcall(game.IsA, object, "LocalScript")
  485. if success and is_localscript then
  486. pcall(Utility.SetProperty, object, "Disabled", true)
  487. local changed_connection = pcall(object.Changed.connect, object.Changed, function(property)
  488. if property == "Disabled" and not object.Disabled then
  489. pcall(Utility.SetProperty, object, "Disabled", true)
  490. object:Destroy()
  491. end
  492. end)
  493. end
  494. if not objects[object] then
  495. object:Destroy()
  496. end
  497. end))
  498. model.Parent = workspace
  499. Player.Character = model
  500. Camera.CameraSubject = humanoid
  501. Camera.CameraType = "Track"
  502. Camera.CoordinateFrame = cameraCFrame
  503. local IsStanding
  504. local RegenerateHealth
  505. local ResetCharacter
  506. function IsStanding()
  507. return not not next(feetTouching)
  508. end
  509. function RegenerateHealth()
  510. if humanoid.Health < 1 then
  511. humanoid.Health = 100
  512. elseif not regeneratingHealth then
  513. regeneratingHealth = true
  514. local elapsedTime = wait(1)
  515. regeneratingHealth = false
  516. if humanoid.Health < 100 then
  517. humanoid.Health = math.min(humanoid.Health + elapsedTime, 100)
  518. end
  519. end
  520. end
  521. function ResetCharacter()
  522. for index, connection in ipairs(connections) do
  523. connection:disconnect()
  524. end
  525. active = false
  526. end
  527. table.insert(connections, model.AncestryChanged:connect(ResetCharacter))
  528. table.insert(connections, model.DescendantRemoving:connect(function(object)
  529. local parent = forcefields[object]
  530. if parent then
  531. forcefields[object] = nil
  532. local new_forcefield = Instance.new("ForceField")
  533. forcefields[new_forcefield] = parent
  534. objects[new_forcefield] = true
  535. new_forcefield.Parent = parent
  536. elseif objects[object] then
  537. ResetCharacter()
  538. end
  539. end))
  540. table.insert(connections, humanoid.HealthChanged:connect(RegenerateHealth))
  541. table.insert(connections, humanoid.Climbing:connect(function() pose = "Climbing" end))
  542. table.insert(connections, humanoid.FallingDown:connect(function(state) pose = "FallingDown" end))
  543. table.insert(connections, humanoid.FreeFalling:connect(function(state) pose = "FreeFall" if state then soundFreeFalling:Play() else
  544.  
  545. soundFreeFalling:Pause() end end))
  546. table.insert(connections, humanoid.GettingUp:connect(function(state) pose = "GettingUp" if state then soundGettingUp:Play() else
  547.  
  548. soundGettingUp:Pause() end end))
  549. table.insert(connections, humanoid.PlatformStanding:connect(function() pose = "PlatformStanding" end))
  550. table.insert(connections, humanoid.Seated:connect(function() pose = "Seated" end))
  551. table.insert(connections, humanoid.Swimming:connect(function(speed) if speed > 0 then pose = "Swimming" else pose = "Standing" end end))
  552. local previousRootPartCFrame = rootPart.CFrame
  553. TaskScheduler.Start(function()
  554. while active do
  555. local totalTime = TaskScheduler.GetCurrentTime()
  556. local stepTime = 1 / 60
  557. if not PlayerControl.characterEnabled then
  558. ResetCharacter()
  559. break
  560. end
  561. torsoLight.Brightness = 0.5 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
  562. local featherfallEnabled = PlayerControl.IsFeatherfallEnabled()
  563. local rootPartCFrame = rootPart.CFrame
  564. if not jumpDebounce and UserInterface:IsKeyDown(Enum.KeyCode.Space) then
  565. if humanoid.Sit then
  566. humanoid.Sit = false
  567. end
  568. if IsStanding() then
  569. jumpDebounce = true
  570. pose = "Jumping"
  571. rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 50, rootPart.Velocity.Z)
  572. torso.Velocity = Vector3.new(torso.Velocity.X, 50, torso.Velocity.Z)
  573. TaskScheduler.Schedule(1, function()
  574. if pose == "Jumping" then
  575. pose = "FreeFall"
  576. end
  577. jumpDebounce = false
  578. humanoid.Jump = false
  579. end)
  580. end
  581. end
  582. local cameraCFrame = Camera.CoordinateFrame
  583. local cameraDirection = cameraCFrame.lookVector
  584. if flying then
  585. if PlayerControl.rolling then
  586. local rootPartCFrame = rootPart.CFrame
  587. local speed = (rootPartCFrame - rootPartCFrame.p):pointToObjectSpace(rootPart.Velocity).Y
  588. local decay = 0.5 ^ stepTime
  589. if math.abs(speed) <= 50 then
  590. PlayerControl.rollingAngle = (((PlayerControl.rollingAngle + 0.5) % 1 - 0.5) * decay) % 1
  591. PlayerControl.rollingOffset = PlayerControl.rollingOffset * decay
  592. else
  593. PlayerControl.rollingAngle = (PlayerControl.rollingAngle + stepTime * speed * PlayerControl.rollingSpeed) % 1
  594. PlayerControl.rollingOffset = (PlayerControl.rollingOffset + PlayerControl.rollingMaxOffset * (1 / decay - 1)) * decay
  595. end
  596. rootJoint.C0 = (CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) * CFrame.Angles(PlayerControl.rollingAngle * 2 * math.pi, 0, 0)) * CFrame.new(0, -PlayerControl.rollingOffset, 0)
  597. else
  598. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  599. PlayerControl.rollingAngle = 0
  600. PlayerControl.rollingOffset = 0
  601. end
  602. rightShoulder.MaxVelocity = 0.5
  603. leftShoulder.MaxVelocity = 0.5
  604. rightShoulder.DesiredAngle = 0
  605. leftShoulder.DesiredAngle = 0
  606. rightHip.DesiredAngle = 0
  607. leftHip.DesiredAngle = 0
  608. bodyGyro.D = 500
  609. bodyGyro.P = 1e6
  610. bodyGyro.maxTorque = Vector3.new(1e6, 1e6, 1e6)
  611. bodyVelocity.P = 1250
  612. bodyVelocity.maxForce = Vector3.new(1e6, 1e6, 1e6)
  613. local movementRight = 0
  614. local movementForward = 0
  615. local movementUp = 0
  616. if UserInterface:IsKeyDown(Enum.KeyCode.A) and not UserInterface:IsKeyDown(Enum.KeyCode.D) then
  617. movementRight = -1
  618. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  619. movementRight = 1
  620. end
  621. if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  622. movementUp = 0.2
  623. if not UserInterface:IsKeyDown(Enum.KeyCode.S) then
  624. movementForward = -1
  625. end
  626. elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  627. movementForward = 1
  628. end
  629. local movement = PlayerControl.fly_acceleration * cameraCFrame:vectorToWorldSpace(Vector3.new(movementRight, movementUp, movementForward))
  630. local previousMomentum = flyingMomentum
  631. local previousTilt = flyingTilt
  632. flyingMomentum = movement + flyingMomentum * (1 - PlayerControl.fly_acceleration / PlayerControl.fly_speed)
  633. flyingTilt = ((flyingMomentum * Vector3.new(1, 0, 1)).unit:Cross((previousMomentum * Vector3.new(1, 0, 1)).unit)).Y
  634. if flyingTilt ~= flyingTilt or flyingTilt == math.huge then
  635. flyingTilt = 0
  636. end
  637. local absoluteTilt = math.abs(flyingTilt)
  638. if absoluteTilt > 0.06 or absoluteTilt < 0.0001 then
  639. if math.abs(previousTilt) > 0.0001 then
  640. flyingTilt = previousTilt * 0.9
  641. else
  642. flyingTilt = 0
  643. end
  644. else
  645. flyingTilt = previousTilt * 0.77 + flyingTilt * 0.25
  646. end
  647. previousTilt = flyingTilt
  648. if flyingMomentum.magnitude < 0.1 then
  649. flyingMomentum = Vector3.new(0, 0, 0)
  650. -- bodyGyro.cframe = cameraCFrame
  651. else
  652. local momentumOrientation = CFrame.new(Vector3.new(0, 0, 0), flyingMomentum)
  653. local tiltOrientation = CFrame.Angles(0, 0, -20 * flyingTilt)
  654. bodyGyro.cframe = momentumOrientation * tiltOrientation * CFrame.Angles(-0.5 * math.pi * math.min(flyingMomentum.magnitude / PlayerControl.fly_speed, 1), 0, 0)
  655. end
  656. bodyVelocity.velocity = flyingMomentum + Vector3.new(0, 0.15695775618683547, 0)
  657. rootPart.Velocity = flyingMomentum
  658. previousMomentum = flyingMomentum
  659. else
  660. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  661. PlayerControl.rollingAngle = 0
  662. PlayerControl.rollingOffset = 0
  663. bodyGyro.D = 3250
  664. bodyGyro.P = 400000
  665. bodyVelocity.P = 5000
  666. local cameraDirection = cameraCFrame.lookVector
  667. local walkDirection = Vector3.new(0, 0, 0)
  668. local walkSpeed = 16
  669. if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  670. if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  671. walkDirection = Vector3.new(cameraDirection.X + cameraDirection.Z, 0, cameraDirection.Z - cameraDirection.X).unit
  672. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  673. walkDirection = Vector3.new(cameraDirection.X - cameraDirection.Z, 0, cameraDirection.Z + cameraDirection.X).unit
  674. else
  675. walkDirection = Vector3.new(cameraDirection.X, 0, cameraDirection.Z).unit
  676. end
  677. elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  678. if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  679. walkDirection = Vector3.new(-cameraDirection.X + cameraDirection.Z, 0, -cameraDirection.Z - cameraDirection.X).unit
  680. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  681. walkDirection = Vector3.new(-cameraDirection.X - cameraDirection.Z, 0, -cameraDirection.Z + cameraDirection.X).unit
  682. else
  683. walkDirection = Vector3.new(-cameraDirection.X, 0, -cameraDirection.Z).unit
  684. end
  685. elseif UserInterface:IsKeyDown(Enum.KeyCode.A) then
  686. walkDirection = Vector3.new(cameraDirection.Z, 0, -cameraDirection.X).unit
  687. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  688. walkDirection = Vector3.new(-cameraDirection.Z, 0, cameraDirection.X).unit
  689. else
  690. walkSpeed = 0
  691. end
  692. if walkSpeed ~= previousWalkSpeed then
  693. if walkSpeed > 0 then
  694. soundRunning:Play()
  695. else
  696. soundRunning:Pause()
  697. end
  698. end
  699. if walkSpeed > 0 then
  700. if pose ~= "Jumping" then
  701. if IsStanding() then
  702. pose = "Running"
  703. else
  704. pose = "FreeFall"
  705. end
  706. end
  707. bodyGyro.cframe = CFrame.new(Vector3.new(), walkDirection)
  708. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000)
  709. bodyVelocity.maxForce = Vector3.new(1000000, maxForceY, 1000000)
  710. else
  711. if pose ~= "Jumping" then
  712. if IsStanding() then
  713. pose = "Standing"
  714. else
  715. pose = "FreeFall"
  716. end
  717. end
  718. -- TODO: find and fix bug that causes torso to rotate back to some angle
  719. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000) -- Vector3.new(1000000000, 0, 1000000000)
  720. if PlayerControl.pushable then
  721. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  722. else
  723. bodyVelocity.maxForce = Vector3.new(1000000, 0, 1000000)
  724. end
  725. end
  726. if featherfallEnabled then
  727. local velocity = rootPart.Velocity
  728. if velocity.Y > 50 then
  729. rootPart.Velocity = Vector3.new(velocity.X, 50, velocity.Z)
  730. elseif velocity.Y < -50 then
  731. rootPart.Velocity = Vector3.new(velocity.X, -50, velocity.Z)
  732. end
  733. local distanceVector = rootPartCFrame.p - previousRootPartCFrame.p
  734. local offsetX, offsetY, offsetZ = distanceVector.X, distanceVector.Y, distanceVector.Z
  735. local MAX_MOVEMENT = 50 * 0.03333333507180214
  736. if offsetX > MAX_MOVEMENT then
  737. offsetX = MAX_MOVEMENT
  738. elseif offsetX < -MAX_MOVEMENT then
  739. offsetX = -MAX_MOVEMENT
  740. end
  741. if offsetY > MAX_MOVEMENT then
  742. offsetY = MAX_MOVEMENT
  743. elseif offsetY < -MAX_MOVEMENT then
  744. offsetY = -MAX_MOVEMENT
  745. end
  746. if offsetZ > MAX_MOVEMENT then
  747. offsetZ = MAX_MOVEMENT
  748. elseif offsetZ < -MAX_MOVEMENT then
  749. offsetZ = -MAX_MOVEMENT
  750. end
  751. local offset = Vector3.new(offsetX, offsetY, offsetZ)
  752. if offset ~= distanceVector then
  753. rootPartCFrame = previousRootPartCFrame + offset
  754. --rootPart.CFrame = rootPartCFrame
  755. end
  756. end
  757. local walkingVelocity = walkDirection * walkSpeed
  758. bodyVelocity.velocity = walkingVelocity
  759. if not jumpDebounce and math.abs(rootPart.Velocity.Y) <= 0.1 then
  760. rootPart.Velocity = Vector3.new(walkingVelocity.X, rootPart.Velocity.Y, walkingVelocity.Z)
  761. end
  762. previousWalkSpeed = walkSpeed
  763. if pose == "Jumping" or jumpDebounce then
  764. rightShoulder.MaxVelocity = 0.5
  765. leftShoulder.MaxVelocity = 0.5
  766. rightShoulder.DesiredAngle = 3.14
  767. leftShoulder.DesiredAngle = -3.14
  768. rightHip.DesiredAngle = 0
  769. leftHip.DesiredAngle = 0
  770. elseif pose == "FreeFall" then
  771. rightShoulder.MaxVelocity = 0.5
  772. leftShoulder.MaxVelocity = 0.5
  773. rightShoulder.DesiredAngle = 3.14
  774. leftShoulder.DesiredAngle = -3.14
  775. rightHip.DesiredAngle = 0
  776. leftHip.DesiredAngle = 0
  777. elseif pose == "Seated" then
  778. rightShoulder.MaxVelocity = 0.15
  779. leftShoulder.MaxVelocity = 0.15
  780. rightShoulder.DesiredAngle = 3.14 / 2
  781. leftShoulder.DesiredAngle = -3.14 / 2
  782. rightHip.DesiredAngle = 3.14 / 2
  783. leftHip.DesiredAngle = -3.14 / 2
  784. else
  785. local climbFudge = 0
  786. local amplitude
  787. local frequency
  788. if pose == "Running" then
  789. rightShoulder.MaxVelocity = 0.15
  790. leftShoulder.MaxVelocity = 0.15
  791. amplitude = 1
  792. frequency = 9
  793. elseif (pose == "Climbing") then
  794. rightShoulder.MaxVelocity = 0.5
  795. leftShoulder.MaxVelocity = 0.5
  796. amplitude = 1
  797. frequency = 9
  798. climbFudge = 3.14
  799. else
  800. amplitude = 0.1
  801. frequency = 1
  802. end
  803. local desiredAngle = amplitude * math.sin(totalTime * frequency)
  804. rightShoulder.DesiredAngle = desiredAngle + climbFudge
  805. leftShoulder.DesiredAngle = desiredAngle - climbFudge
  806. rightHip.DesiredAngle = -desiredAngle
  807. leftHip.DesiredAngle = -desiredAngle
  808. end
  809. end
  810. previousRootPartCFrame = rootPartCFrame
  811. RunService.RenderStepped:wait()
  812. end
  813. if model.Parent ~= nil then
  814. model.Parent = nil
  815. end
  816. PlayerControl.CreateCharacter()
  817. end)
  818. humanoid.Health = 100
  819. character = model
  820. end
  821. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement