DerpedOutModzYT

Untitled

May 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 95.45 KB | None | 0 0
  1. local updateHand = false
  2. local Changelog = [[
  3.  
  4. Redstone coming soon. (not... sorry)
  5. Note (Read!): It will be a very long while till this script gets
  6. updated again, i stopped updating this since im focusing more on other things
  7. like C++ programming and game development, i'm not really that active much
  8. in roblox (and if im off im probably programming), so yeah, maybe in a
  9. million years i'll come back to update the script again (:P).
  10. 09/03/2018:
  11. + Added the heart bar.
  12. + Added death animation.
  13. * Your camera now shakes like in minecraft when hurt.
  14. * Toolbar Selection GUI now is accurate.
  15.  
  16. 02/03/2018:
  17. * Fixed a bug with the textures.
  18.  
  19. 01/03/2018:
  20. + Added a global grid.
  21. + Added something that i'm not sure how to describe.
  22. * Punching Animation in first person is now more accurate.
  23.  
  24. 17/02/2018:
  25. + You can't break your neck anymore (360 head you know)
  26. + Added this changelog
  27. - Removed the name tag, since it causes it to get banned on
  28. some servers for some reason (really voidacity?).
  29. * Walking animation is now more accurate
  30.  
  31. Note: It's been a while since i don't update the script, but i'll
  32. get back to updating it.
  33.  
  34. 05/02/2018:
  35. + Added gravity to sand and gravel (WARNING: Can be laggy!)
  36.  
  37. 04/02/2018:
  38. + Added creative inventory
  39. + Added 31 blocks (that's a lot, but not near minecraft's level)
  40. + Added sprinting (i'll add footsteps and particles later)
  41. - Removed Herobrine
  42. * Fixed a bug where the hand dissapears if u look down while sneaking
  43. * Fixed? (not sure) a bug where if u ran the script you would die
  44.  
  45. 01/02/2018:
  46. + Added the hand that appears on minecraft when ur first person
  47. + Added a walking animation to the hand
  48. + Punching animation added to the hand
  49. + Camera bobbing
  50. + Sneaking now lowers your camera just like in minecraft
  51. + Blocks now have sounds (i chose the ones that are the closest to minecraft sounds)
  52. + When a block is broken, particles will fall from it
  53. ]]
  54.  
  55. workspace:WaitForChild("Camera"):ClearAllChildren()
  56. local RS = game:GetService("RunService").RenderStepped
  57. local targetName = game.Players.LocalPlayer.Name
  58. local player = game.Players:FindFirstChild(targetName)
  59.  
  60. local creativeInventory = {
  61. {
  62. name = "Dirt",
  63. size = Vector3.new(2.6, 2.6, 2.6),
  64. transparency = 0;
  65. frontTex = "rbxassetid://152569532",
  66. backTex = "rbxassetid://152569532",
  67. topTex = "rbxassetid://152569532",
  68. bottomTex = "rbxassetid://152569532",
  69. leftTex = "rbxassetid://152569532",
  70. rightTex = "rbxassetid://152569532",
  71. displayTex = "",
  72. sound = "rbxassetid://1102186681",
  73. soundVol = 1.25,
  74. hasGravity = false,
  75. objectType = "Block"
  76. },
  77. {
  78. name = "Grass",
  79. size = Vector3.new(2.6, 2.6, 2.6),
  80. transparency = 0;
  81. frontTex = "rbxassetid://96430337",
  82. backTex = "rbxassetid://96430337",
  83. topTex = "rbxassetid://96430265",
  84. bottomTex = "rbxassetid://179655033",
  85. leftTex = "rbxassetid://96430337",
  86. rightTex = "rbxassetid://96430337",
  87. displayTex = "",
  88. sound = "rbxassetid://1102186681",
  89. soundVol = 1.25,
  90. hasGravity = false,
  91. objectType = "Block"
  92. },
  93. {
  94. name = "Sand",
  95. size = Vector3.new(2.6, 2.6, 2.6),
  96. transparency = 0;
  97. frontTex = "rbxassetid://347007448",
  98. backTex = "rbxassetid://347007448",
  99. topTex = "rbxassetid://347007448",
  100. bottomTex = "rbxassetid://347007448",
  101. leftTex = "rbxassetid://347007448",
  102. rightTex = "rbxassetid://347007448",
  103. displayTex = "",
  104. sound = "rbxassetid://1102186681",
  105. soundVol = 1.25,
  106. hasGravity = true,
  107. objectType = "Block"
  108. },
  109. {
  110. name = "Gravel",
  111. size = Vector3.new(2.6, 2.6, 2.6),
  112. transparency = 0;
  113. frontTex = "rbxassetid://151701568",
  114. backTex = "rbxassetid://151701568",
  115. topTex = "rbxassetid://151701568",
  116. bottomTex = "rbxassetid://151701568",
  117. leftTex = "rbxassetid://151701568",
  118. rightTex = "rbxassetid://151701568",
  119. displayTex = "",
  120. sound = "rbxassetid://1102186681",
  121. soundVol = 1.25,
  122. hasGravity = true,
  123. objectType = "Block"
  124. },
  125. {
  126. name = "Stone",
  127. size = Vector3.new(2.6, 2.6, 2.6),
  128. transparency = 0;
  129. frontTex = "rbxassetid://75880927",
  130. backTex = "rbxassetid://75880927",
  131. topTex = "rbxassetid://75880927",
  132. bottomTex = "rbxassetid://75880927",
  133. leftTex = "rbxassetid://75880927",
  134. rightTex = "rbxassetid://75880927",
  135. displayTex = "",
  136. sound = "rbxassetid://1016978163",
  137. soundVol = 2,
  138. hasGravity = false,
  139. objectType = "Block"
  140. },
  141. {
  142. name = "Diamond Ore",
  143. size = Vector3.new(2.6, 2.6, 2.6),
  144. transparency = 0;
  145. frontTex = "rbxassetid://57928490",
  146. backTex = "rbxassetid://57928490",
  147. topTex = "rbxassetid://57928490",
  148. bottomTex = "rbxassetid://57928490",
  149. leftTex = "rbxassetid://57928490",
  150. rightTex = "rbxassetid://57928490",
  151. displayTex = "",
  152. sound = "rbxassetid://1016978163",
  153. soundVol = 2,
  154. hasGravity = false,
  155. objectType = "Block"
  156. },
  157. {
  158. name = "Diamond Block",
  159. size = Vector3.new(2.6, 2.6, 2.6),
  160. transparency = 0;
  161. frontTex = "rbxassetid://56749955",
  162. backTex = "rbxassetid://56749955",
  163. topTex = "rbxassetid://56749955",
  164. bottomTex = "rbxassetid://56749955",
  165. leftTex = "rbxassetid://56749955",
  166. rightTex = "rbxassetid://56749955",
  167. displayTex = "",
  168. sound = "rbxassetid://1016978163",
  169. soundVol = 2,
  170. hasGravity = false,
  171. objectType = "Block"
  172. },
  173. {
  174. name = "Emerald Block",
  175. size = Vector3.new(2.6, 2.6, 2.6),
  176. transparency = 0;
  177. frontTex = "rbxassetid://152410853",
  178. backTex = "rbxassetid://152410853",
  179. topTex = "rbxassetid://152410853",
  180. bottomTex = "rbxassetid://152410853",
  181. leftTex = "rbxassetid://152410853",
  182. rightTex = "rbxassetid://152410853",
  183. displayTex = "",
  184. sound = "rbxassetid://1016978163",
  185. soundVol = 2,
  186. hasGravity = false,
  187. objectType = "Block"
  188. },
  189. {
  190. name = "Emerald Ore",
  191. size = Vector3.new(2.6, 2.6, 2.6),
  192. transparency = 0;
  193. frontTex = "rbxassetid://152410868",
  194. backTex = "rbxassetid://152410868",
  195. topTex = "rbxassetid://152410868",
  196. bottomTex = "rbxassetid://152410868",
  197. leftTex = "rbxassetid://152410868",
  198. rightTex = "rbxassetid://152410868",
  199. displayTex = "",
  200. sound = "rbxassetid://1016978163",
  201. soundVol = 2,
  202. hasGravity = false,
  203. objectType = "Block"
  204. },
  205. {
  206. name = "Obsidian",
  207. size = Vector3.new(2.6, 2.6, 2.6),
  208. transparency = 0;
  209. frontTex = "rbxassetid://112560322",
  210. backTex = "rbxassetid://112560322",
  211. topTex = "rbxassetid://112560322",
  212. bottomTex = "rbxassetid://112560322",
  213. leftTex = "rbxassetid://112560322",
  214. rightTex = "rbxassetid://112560322",
  215. displayTex = "",
  216. sound = "rbxassetid://1016978163",
  217. soundVol = 2,
  218. hasGravity = false,
  219. objectType = "Block"
  220. },
  221. {
  222. name = "Gold Block",
  223. size = Vector3.new(2.6, 2.6, 2.6),
  224. transparency = 0;
  225. frontTex = "rbxassetid://152572128",
  226. backTex = "rbxassetid://152572128",
  227. topTex = "rbxassetid://152572128",
  228. bottomTex = "rbxassetid://152572128",
  229. leftTex = "rbxassetid://152572128",
  230. rightTex = "rbxassetid://152572128",
  231. displayTex = "",
  232. sound = "rbxassetid://1016978163",
  233. soundVol = 2,
  234. hasGravity = false,
  235. objectType = "Block"
  236. },
  237. {
  238. name = "Gold Ore",
  239. size = Vector3.new(2.6, 2.6, 2.6),
  240. transparency = 0;
  241. frontTex = "rbxassetid://152572121",
  242. backTex = "rbxassetid://152572121",
  243. topTex = "rbxassetid://152572121",
  244. bottomTex = "rbxassetid://152572121",
  245. leftTex = "rbxassetid://152572121",
  246. rightTex = "rbxassetid://152572121",
  247. displayTex = "",
  248. sound = "rbxassetid://1016978163",
  249. soundVol = 2,
  250. hasGravity = false,
  251. objectType = "Block"
  252. },
  253. {
  254. name = "Iron Block",
  255. size = Vector3.new(2.6, 2.6, 2.6),
  256. transparency = 0;
  257. frontTex = "rbxassetid://152572134",
  258. backTex = "rbxassetid://152572134",
  259. topTex = "rbxassetid://152572134",
  260. bottomTex = "rbxassetid://152572134",
  261. leftTex = "rbxassetid://152572134",
  262. rightTex = "rbxassetid://152572134",
  263. displayTex = "",
  264. sound = "rbxassetid://1016978163",
  265. soundVol = 2,
  266. hasGravity = false,
  267. objectType = "Block"
  268. },
  269. {
  270. name = "Iron Ore",
  271. size = Vector3.new(2.6, 2.6, 2.6),
  272. transparency = 0;
  273. frontTex = "rbxassetid://132879562",
  274. backTex = "rbxassetid://132879562",
  275. topTex = "rbxassetid://132879562",
  276. bottomTex = "rbxassetid://132879562",
  277. leftTex = "rbxassetid://132879562",
  278. rightTex = "rbxassetid://132879562",
  279. displayTex = "",
  280. sound = "rbxassetid://1016978163",
  281. soundVol = 2,
  282. hasGravity = false,
  283. objectType = "Block"
  284. },
  285. {
  286. name = "Redstone Block",
  287. size = Vector3.new(2.6, 2.6, 2.6),
  288. transparency = 0;
  289. frontTex = "rbxassetid://136260219",
  290. backTex = "rbxassetid://136260219",
  291. topTex = "rbxassetid://136260219",
  292. bottomTex = "rbxassetid://136260219",
  293. leftTex = "rbxassetid://136260219",
  294. rightTex = "rbxassetid://136260219",
  295. sound = "rbxassetid://1016978163",
  296. soundVol = 2,
  297. hasGravity = false,
  298. objectType = "Block"
  299. },
  300. {
  301. name = "Redstone Ore",
  302. size = Vector3.new(2.6, 2.6, 2.6),
  303. transparency = 0;
  304. frontTex = "rbxassetid://152572209",
  305. backTex = "rbxassetid://152572209",
  306. topTex = "rbxassetid://152572209",
  307. bottomTex = "rbxassetid://152572209",
  308. leftTex = "rbxassetid://152572209",
  309. rightTex = "rbxassetid://152572209",
  310. displayTex = "",
  311. sound = "rbxassetid://1016978163",
  312. soundVol = 2,
  313. hasGravity = false,
  314. objectType = "Block"
  315. },
  316. {
  317. name = "Coal Block",
  318. size = Vector3.new(2.6, 2.6, 2.6),
  319. transparency = 0;
  320. frontTex = "rbxassetid://152527418",
  321. backTex = "rbxassetid://152527418",
  322. topTex = "rbxassetid://152527418",
  323. bottomTex = "rbxassetid://152527418",
  324. leftTex = "rbxassetid://152527418",
  325. rightTex = "rbxassetid://152527418",
  326. displayTex = "",
  327. sound = "rbxassetid://1016978163",
  328. soundVol = 2,
  329. hasGravity = false,
  330. objectType = "Block"
  331. },
  332. {
  333. name = "Coal Ore",
  334. size = Vector3.new(2.6, 2.6, 2.6),
  335. transparency = 0;
  336. frontTex = "rbxassetid://152572101",
  337. backTex = "rbxassetid://152572101",
  338. topTex = "rbxassetid://152572101",
  339. bottomTex = "rbxassetid://152572101",
  340. leftTex = "rbxassetid://152572101",
  341. rightTex = "rbxassetid://152572101",
  342. displayTex = "",
  343. sound = "rbxassetid://1016978163",
  344. soundVol = 2,
  345. hasGravity = false,
  346. objectType = "Block"
  347. },
  348. {
  349. name = "Bedrock",
  350. size = Vector3.new(2.6, 2.6, 2.6),
  351. transparency = 0;
  352. frontTex = "rbxassetid://75881126",
  353. backTex = "rbxassetid://75881126",
  354. topTex = "rbxassetid://75881126",
  355. bottomTex = "rbxassetid://75881126",
  356. leftTex = "rbxassetid://75881126",
  357. rightTex = "rbxassetid://75881126",
  358. displayTex = "",
  359. sound = "rbxassetid://1016978163",
  360. soundVol = 2,
  361. hasGravity = false,
  362. objectType = "Block"
  363. },
  364. {
  365. name = "Cobblestone",
  366. size = Vector3.new(2.6, 2.6, 2.6),
  367. transparency = 0;
  368. frontTex = "rbxassetid://152572105",
  369. backTex = "rbxassetid://152572105",
  370. topTex = "rbxassetid://152572105",
  371. bottomTex = "rbxassetid://152572105",
  372. leftTex = "rbxassetid://152572105",
  373. rightTex = "rbxassetid://152572105",
  374. displayTex = "",
  375. sound = "rbxassetid://1016978163",
  376. soundVol = 2,
  377. hasGravity = false,
  378. objectType = "Block"
  379. },
  380. {
  381. name = "Mossy Stone Brick",
  382. size = Vector3.new(2.6, 2.6, 2.6),
  383. transparency = 0;
  384. frontTex = "rbxassetid://61826751",
  385. backTex = "rbxassetid://61826751",
  386. topTex = "rbxassetid://61826751",
  387. bottomTex = "rbxassetid://61826751",
  388. leftTex = "rbxassetid://61826751",
  389. rightTex = "rbxassetid://61826751",
  390. displayTex = "",
  391. sound = "rbxassetid://1016978163",
  392. soundVol = 2,
  393. hasGravity = false,
  394. objectType = "Block"
  395. },
  396. {
  397. name = "Cracked Stone Brick",
  398. size = Vector3.new(2.6, 2.6, 2.6),
  399. transparency = 0;
  400. frontTex = "rbxassetid://151802087",
  401. backTex = "rbxassetid://151802087",
  402. topTex = "rbxassetid://151802087",
  403. bottomTex = "rbxassetid://151802087",
  404. leftTex = "rbxassetid://151802087",
  405. rightTex = "rbxassetid://151802087",
  406. displayTex = "",
  407. sound = "rbxassetid://1016978163",
  408. soundVol = 2,
  409. hasGravity = false,
  410. objectType = "Block"
  411. },
  412. {
  413. name = "Chiseled Stone Brick",
  414. size = Vector3.new(2.6, 2.6, 2.6),
  415. transparency = 0;
  416. frontTex = "rbxassetid://151802074",
  417. backTex = "rbxassetid://151802074",
  418. topTex = "rbxassetid://151802074",
  419. bottomTex = "rbxassetid://151802074",
  420. leftTex = "rbxassetid://151802074",
  421. rightTex = "rbxassetid://151802074",
  422. displayTex = "",
  423. sound = "rbxassetid://1016978163",
  424. soundVol = 2,
  425. hasGravity = false,
  426. objectType = "Block"
  427. },
  428. {
  429. name = "Stone Brick",
  430. size = Vector3.new(2.6, 2.6, 2.6),
  431. transparency = 0;
  432. frontTex = "rbxassetid://61826773",
  433. backTex = "rbxassetid://61826773",
  434. topTex = "rbxassetid://61826773",
  435. bottomTex = "rbxassetid://61826773",
  436. leftTex = "rbxassetid://61826773",
  437. rightTex = "rbxassetid://61826773",
  438. displayTex = "",
  439. sound = "rbxassetid://1016978163",
  440. soundVol = 2,
  441. hasGravity = false,
  442. objectType = "Block"
  443. },
  444. {
  445. name = "Nether Brick",
  446. size = Vector3.new(2.6, 2.6, 2.6),
  447. transparency = 0;
  448. frontTex = "rbxassetid://151802104",
  449. backTex = "rbxassetid://151802104",
  450. topTex = "rbxassetid://151802104",
  451. bottomTex = "rbxassetid://151802104",
  452. leftTex = "rbxassetid://151802104",
  453. rightTex = "rbxassetid://151802104",
  454. displayTex = "",
  455. sound = "rbxassetid://1016978163",
  456. soundVol = 2,
  457. hasGravity = false,
  458. objectType = "Block"
  459. },
  460. {
  461. name = "Granite",
  462. size = Vector3.new(2.6, 2.6, 2.6),
  463. transparency = 0;
  464. frontTex = "rbxassetid://151776467",
  465. backTex = "rbxassetid://151776467",
  466. topTex = "rbxassetid://151776467",
  467. bottomTex = "rbxassetid://151776467",
  468. leftTex = "rbxassetid://151776467",
  469. rightTex = "rbxassetid://151776467",
  470. displayTex = "",
  471. sound = "rbxassetid://1016978163",
  472. soundVol = 2,
  473. hasGravity = false,
  474. objectType = "Block"
  475. },
  476. {
  477. name = "Diorite",
  478. size = Vector3.new(2.6, 2.6, 2.6),
  479. transparency = 0;
  480. frontTex = "rbxassetid://151776452",
  481. backTex = "rbxassetid://151776452",
  482. topTex = "rbxassetid://151776452",
  483. bottomTex = "rbxassetid://151776452",
  484. leftTex = "rbxassetid://151776452",
  485. rightTex = "rbxassetid://151776452",
  486. sound = "rbxassetid://1016978163",
  487. soundVol = 2,
  488. hasGravity = false,
  489. objectType = "Block"
  490. },
  491. {
  492. name = "Andesite",
  493. size = Vector3.new(2.6, 2.6, 2.6),
  494. transparency = 0;
  495. frontTex = "rbxassetid://151776422",
  496. backTex = "rbxassetid://151776422",
  497. topTex = "rbxassetid://151776422",
  498. bottomTex = "rbxassetid://151776422",
  499. leftTex = "rbxassetid://151776422",
  500. rightTex = "rbxassetid://151776422",
  501. displayTex = "",
  502. sound = "rbxassetid://1016978163",
  503. soundVol = 2,
  504. hasGravity = false,
  505. objectType = "Block"
  506. },
  507. {
  508. name = "Polished Granite",
  509. size = Vector3.new(2.6, 2.6, 2.6),
  510. transparency = 0;
  511. frontTex = "rbxassetid://151776506",
  512. backTex = "rbxassetid://151776506",
  513. topTex = "rbxassetid://151776506",
  514. bottomTex = "rbxassetid://151776506",
  515. leftTex = "rbxassetid://151776506",
  516. rightTex = "rbxassetid://151776506",
  517. displayTex = "",
  518. sound = "rbxassetid://1016978163",
  519. soundVol = 2,
  520. hasGravity = false,
  521. objectType = "Block"
  522. },
  523. {
  524. name = "Polished Diorite",
  525. size = Vector3.new(2.6, 2.6, 2.6),
  526. transparency = 0;
  527. frontTex = "rbxassetid://151776533",
  528. backTex = "rbxassetid://151776533",
  529. topTex = "rbxassetid://151776533",
  530. bottomTex = "rbxassetid://151776533",
  531. leftTex = "rbxassetid://151776533",
  532. rightTex = "rbxassetid://151776533",
  533. displayTex = "",
  534. sound = "rbxassetid://1016978163",
  535. soundVol = 2,
  536. hasGravity = false,
  537. objectType = "Block"
  538. },
  539. {
  540. name = "Polished Andesite",
  541. size = Vector3.new(2.6, 2.6, 2.6),
  542. transparency = 0;
  543. frontTex = "rbxassetid://151776506",
  544. backTex = "rbxassetid://151776506",
  545. topTex = "rbxassetid://151776506",
  546. bottomTex = "rbxassetid://151776506",
  547. leftTex = "rbxassetid://151776506",
  548. rightTex = "rbxassetid://151776506",
  549. displayTex = "",
  550. sound = "rbxassetid://1016978163",
  551. soundVol = 2,
  552. hasGravity = false,
  553. objectType = "Block"
  554. },
  555. {
  556. name = "Brick Block",
  557. size = Vector3.new(2.6, 2.6, 2.6),
  558. transparency = 0;
  559. frontTex = "rbxassetid://59389191",
  560. backTex = "rbxassetid://59389191",
  561. topTex = "rbxassetid://59389191",
  562. bottomTex = "rbxassetid://59389191",
  563. leftTex = "rbxassetid://59389191",
  564. rightTex = "rbxassetid://59389191",
  565. displayTex = "",
  566. sound = "rbxassetid://1016978163",
  567. soundVol = 2,
  568. hasGravity = false,
  569. objectType = "Block"
  570. },
  571. {
  572. name = "Packed Ice",
  573. size = Vector3.new(2.6, 2.6, 2.6),
  574. transparency = 0;
  575. frontTex = "rbxassetid://152528023",
  576. backTex = "rbxassetid://152528023",
  577. topTex = "rbxassetid://152528023",
  578. bottomTex = "rbxassetid://152528023",
  579. leftTex = "rbxassetid://152528023",
  580. rightTex = "rbxassetid://152528023",
  581. displayTex = "",
  582. sound = "rbxassetid://1016978163",
  583. soundVol = 2,
  584. hasGravity = false,
  585. objectType = "Block"
  586. },
  587. {
  588. name = "Ice Block",
  589. size = Vector3.new(2.6, 2.6, 2.6),
  590. transparency = 1;
  591. frontTex = "rbxassetid://118555586",
  592. backTex = "rbxassetid://118555586",
  593. topTex = "rbxassetid://118555586",
  594. bottomTex = "rbxassetid://118555586",
  595. leftTex = "rbxassetid://118555586",
  596. rightTex = "rbxassetid://118555586",
  597. displayTex = "",
  598. sound = "rbxassetid://1016978163",
  599. soundVol = 2,
  600. hasGravity = false,
  601. objectType = "Block"
  602. },
  603. {
  604. name = "Netherrack",
  605. size = Vector3.new(2.6, 2.6, 2.6),
  606. transparency = 0;
  607. frontTex = "rbxassetid://151802119",
  608. backTex = "rbxassetid://151802119",
  609. topTex = "rbxassetid://151802119",
  610. bottomTex = "rbxassetid://151802119",
  611. leftTex = "rbxassetid://151802119",
  612. rightTex = "rbxassetid://151802119",
  613. displayTex = "",
  614. sound = "rbxassetid://1016978163",
  615. soundVol = 2,
  616. hasGravity = false,
  617. objectType = "Block"
  618. },
  619. {
  620. name = "End Stone",
  621. size = Vector3.new(2.6, 2.6, 2.6),
  622. transparency = 0;
  623. frontTex = "rbxassetid://151802091",
  624. backTex = "rbxassetid://151802091",
  625. topTex = "rbxassetid://151802091",
  626. bottomTex = "rbxassetid://151802091",
  627. leftTex = "rbxassetid://151802091",
  628. rightTex = "rbxassetid://151802091",
  629. displayTex = "",
  630. sound = "rbxassetid://1016978163",
  631. soundVol = 2,
  632. hasGravity = false,
  633. objectType = "Block"
  634. },
  635. {
  636. name = "Glass Block",
  637. size = Vector3.new(2.6, 2.6, 2.6),
  638. transparency = 1;
  639. frontTex = "rbxassetid://152239003",
  640. backTex = "rbxassetid://152239003",
  641. topTex = "rbxassetid://152239003",
  642. bottomTex = "rbxassetid://152239003",
  643. leftTex = "rbxassetid://152239003",
  644. rightTex = "rbxassetid://152239003",
  645. displayTex = "",
  646. sound = "rbxassetid://1016978163",
  647. soundVol = 2,
  648. hasGravity = false,
  649. objectType = "Block"
  650. },
  651. {
  652. name = "Glowstone",
  653. size = Vector3.new(2.6, 2.6, 2.6),
  654. transparency = 0;
  655. frontTex = "rbxassetid://54790811",
  656. backTex = "rbxassetid://54790811",
  657. topTex = "rbxassetid://54790811",
  658. bottomTex = "rbxassetid://54790811",
  659. leftTex = "rbxassetid://54790811",
  660. rightTex = "rbxassetid://54790811",
  661. displayTex = "",
  662. sound = "rbxassetid://1016978163",
  663. soundVol = 2,
  664. hasGravity = false,
  665. objectType = "Block"
  666. },
  667. {
  668. name = "Bookshelf",
  669. size = Vector3.new(2.6, 2.6, 2.6),
  670. transparency = 0;
  671. frontTex = "rbxassetid://118554092",
  672. backTex = "rbxassetid://118554092",
  673. topTex = "rbxassetid://346201871",
  674. bottomTex = "rbxassetid://346201871",
  675. leftTex = "rbxassetid://118554092",
  676. rightTex = "rbxassetid://118554092",
  677. displayTex = "",
  678. sound = "rbxassetid://507863457",
  679. soundVol = 2,
  680. hasGravity = false,
  681. objectType = "Block"
  682. },
  683. {
  684. name = "Oak Wood Planks",
  685. size = Vector3.new(2.6, 2.6, 2.6),
  686. transparency = 0;
  687. frontTex = "rbxassetid://346201871",
  688. backTex = "rbxassetid://346201871",
  689. topTex = "rbxassetid://346201871",
  690. bottomTex = "rbxassetid://346201871",
  691. leftTex = "rbxassetid://346201871",
  692. rightTex = "rbxassetid://346201871",
  693. displayTex = "",
  694. sound = "rbxassetid://507863457",
  695. soundVol = 2,
  696. hasGravity = false,
  697. objectType = "Block"
  698. },
  699. {
  700. name = "Oak Log",
  701. size = Vector3.new(2.6, 2.6, 2.6),
  702. transparency = 0;
  703. frontTex = "rbxassetid://71445924",
  704. backTex = "rbxassetid://71445924",
  705. topTex = "rbxassetid://152538557",
  706. bottomTex = "rbxassetid://152538557",
  707. leftTex = "rbxassetid://71445924",
  708. rightTex = "rbxassetid://71445924",
  709. displayTex = "",
  710. sound = "rbxassetid://507863457",
  711. soundVol = 2,
  712. hasGravity = false,
  713. objectType = "Block"
  714. },
  715. {
  716. name = "Oak Leaves",
  717. size = Vector3.new(2.6, 2.6, 2.6),
  718. transparency = 1;
  719. frontTex = "rbxassetid://151708391",
  720. backTex = "rbxassetid://151708391",
  721. topTex = "rbxassetid://151708391",
  722. bottomTex = "rbxassetid://151708391",
  723. leftTex = "rbxassetid://151708391",
  724. rightTex = "rbxassetid://151708391",
  725. displayTex = "",
  726. sound = "rbxassetid://507863457",
  727. -- couldn't find a leaves sound for this one, sorry lol
  728. soundVol = 2,
  729. hasGravity = false,
  730. objectType = "Block"
  731. }
  732. }
  733. local toolBar = {
  734. {
  735. name = "Dirt Block",
  736. size = Vector3.new(2.6, 2.6, 2.6),
  737. transparency = 0;
  738. frontTex = "rbxassetid://152569532",
  739. backTex = "rbxassetid://152569532",
  740. topTex = "rbxassetid://152569532",
  741. bottomTex = "rbxassetid://152569532",
  742. leftTex = "rbxassetid://152569532",
  743. rightTex = "rbxassetid://152569532",
  744. displayTex = "",
  745. sound = "rbxassetid://1102186681",
  746. soundVol = 1.25,
  747. hasGravity = false,
  748. objectType = "Block"
  749. },
  750. {
  751. name = "Grass Block",
  752. size = Vector3.new(2.6, 2.6, 2.6),
  753. transparency = 0;
  754. frontTex = "rbxassetid://96430337",
  755. backTex = "rbxassetid://96430337",
  756. topTex = "rbxassetid://96430265",
  757. bottomTex = "rbxassetid://179655033",
  758. leftTex = "rbxassetid://96430337",
  759. rightTex = "rbxassetid://96430337",
  760. displayTex = "",
  761. sound = "rbxassetid://1102186681",
  762. soundVol = 1.25,
  763. hasGravity = false,
  764. objectType = "Block"
  765. },
  766. {
  767. name = "Stone",
  768. size = Vector3.new(2.6, 2.6, 2.6),
  769. transparency = 0;
  770. frontTex = "rbxassetid://75880927",
  771. backTex = "rbxassetid://75880927",
  772. topTex = "rbxassetid://75880927",
  773. bottomTex = "rbxassetid://75880927",
  774. leftTex = "rbxassetid://75880927",
  775. rightTex = "rbxassetid://75880927",
  776. displayTex = "",
  777. sound = "rbxassetid://1016978163",
  778. soundVol = 2,
  779. hasGravity = false,
  780. objectType = "Block"
  781. },
  782. {
  783. name = "Diamond Ore",
  784. size = Vector3.new(2.6, 2.6, 2.6),
  785. transparency = 0;
  786. frontTex = "rbxassetid://57928490",
  787. backTex = "rbxassetid://57928490",
  788. topTex = "rbxassetid://57928490",
  789. bottomTex = "rbxassetid://57928490",
  790. leftTex = "rbxassetid://57928490",
  791. rightTex = "rbxassetid://57928490",
  792. displayTex = "",
  793. sound = "rbxassetid://1016978163",
  794. soundVol = 2,
  795. hasGravity = false,
  796. objectType = "Block"
  797. },
  798. {
  799. name = "Diamond Block",
  800. size = Vector3.new(2.6, 2.6, 2.6),
  801. transparency = 0;
  802. frontTex = "rbxassetid://56749955",
  803. backTex = "rbxassetid://56749955",
  804. topTex = "rbxassetid://56749955",
  805. bottomTex = "rbxassetid://56749955",
  806. leftTex = "rbxassetid://56749955",
  807. rightTex = "rbxassetid://56749955",
  808. displayTex = "",
  809. sound = "rbxassetid://1016978163",
  810. soundVol = 2,
  811. hasGravity = false,
  812. objectType = "Block"
  813. },
  814. {
  815. name = "Oak Wood Planks",
  816. size = Vector3.new(2.6, 2.6, 2.6),
  817. transparency = 0;
  818. frontTex = "rbxassetid://346201871",
  819. backTex = "rbxassetid://346201871",
  820. topTex = "rbxassetid://346201871",
  821. bottomTex = "rbxassetid://346201871",
  822. leftTex = "rbxassetid://346201871",
  823. rightTex = "rbxassetid://346201871",
  824. displayTex = "",
  825. sound = "rbxassetid://507863457",
  826. soundVol = 2,
  827. hasGravity = false,
  828. objectType = "Block"
  829. },
  830. {
  831. name = "Oak Log",
  832. size = Vector3.new(2.6, 2.6, 2.6),
  833. transparency = 0;
  834. frontTex = "rbxassetid://71445924",
  835. backTex = "rbxassetid://71445924",
  836. topTex = "rbxassetid://152538557",
  837. bottomTex = "rbxassetid://152538557",
  838. leftTex = "rbxassetid://71445924",
  839. rightTex = "rbxassetid://71445924",
  840. displayTex = "",
  841. sound = "rbxassetid://507863457",
  842. soundVol = 2,
  843. hasGravity = false,
  844. objectType = "Block"
  845. }
  846. --[[{
  847. name = "Redstone",
  848. size = Vector3.new(2.6, 0.05, 2.6),
  849. transparency = 1;
  850. frontTex = "rbxassetid://151911305",
  851. backTex = "",
  852. topTex = "rbxassetid://151911305",
  853. bottomTex = "",
  854. leftTex = "",
  855. rightTex = "",
  856. displayTex = "rbxassetid://64124418",
  857. sound = "rbxassetid://1016978163",
  858. soundVol = 2,
  859. hasGravity = false,
  860. objectType = "Redstone Dust"
  861. },]]
  862. }
  863. function putTexture(part, frontF, backF, topF, bottomF, leftF, rightF, className)
  864. local faces = {"Front", "Back", "Top", "Bottom", "Left", "Right"}
  865. for i,f in pairs(faces) do
  866. local decal = Instance.new(className, part)
  867. if i == 1 then decal.Texture = frontF decal.Name = f end
  868. if i == 2 then decal.Texture = backF or frontF decal.Name = f end
  869. if i == 3 then decal.Texture = topF or frontF decal.Name = f end
  870. if i == 4 then decal.Texture = bottomF or frontF decal.Name = f end
  871. if i == 5 then decal.Texture = leftF or frontF decal.Name = f end
  872. if i == 6 then decal.Texture = rightF or frontF decal.Name = f end
  873. decal.Face = f
  874. end
  875. return part
  876. end
  877. function makeSquare(position, size, color, transparency, parent, zindex)
  878. local label = Instance.new("TextLabel", parent)
  879. label.Text = ""
  880. label.BorderSizePixel = 0
  881. label.BackgroundTransparency = transparency
  882. label.Position = position
  883. label.Size = size
  884. label.BackgroundColor3 = color
  885. if zindex == nil then label.ZIndex = 1 else label.ZIndex = zindex end
  886. return label
  887. end
  888. function makeImage(position, size, image, parent, zindex)
  889. local imglabel = Instance.new("ImageLabel", parent)
  890. imglabel.BorderSizePixel = 0
  891. imglabel.BackgroundTransparency = 1
  892. imglabel.Position = position
  893. imglabel.Size = size
  894. imglabel.Image = image
  895. if zindex == nil then imglabel.ZIndex = 1 else imglabel.ZIndex = zindex end
  896. return imglabel
  897. end
  898. function putInventorySlot(position, image, parent, zindex)
  899. local button = Instance.new("TextButton", parent)
  900. button.Position = position
  901. button.Size = UDim2.new(0, 36, 0, 36)
  902. button.BackgroundColor3 = Color3.new(139/255, 139/255, 139/255)
  903. button.Text = ""
  904. button.BorderSizePixel = 0
  905. button.ZIndex = zindex
  906. local imageLabel = Instance.new("ImageLabel", button)
  907. imageLabel.BackgroundTransparency = 0.9
  908. imageLabel.Position = UDim2.new(0, 2, 0, 2)
  909. imageLabel.Size = UDim2.new(0, 32, 0, 32)
  910. imageLabel.Image = image
  911. imageLabel.BorderSizePixel = 0
  912. imageLabel.ZIndex = zindex
  913. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 34, 0, 2),
  914. Color3.new(55/255, 55/255, 55/255), 0, button, zindex)
  915. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 2, 0, 34),
  916. Color3.new(55/255, 55/255, 55/255), 0, button, zindex)
  917. makeSquare(UDim2.new(0, 34, 0, 2), UDim2.new(0, 2, 0, 34),
  918. Color3.new(255/255, 255/255, 255/255), 0, button, zindex)
  919. makeSquare(UDim2.new(0, 2, 0, 34), UDim2.new(0, 34, 0, 2),
  920. Color3.new(255/255, 255/255, 255/255), 0, button, zindex)
  921. return button
  922. end
  923.  
  924. function AngleDifference(Angle1, Angle2)
  925. local Difference = {X = 0, Y = 0, Z = 0}
  926. Difference.X = Angle2.X - Angle1.X
  927.  
  928. if (Difference.X > 180) then
  929. Difference.X = Difference.X - 360
  930. elseif (Difference.X < -180) then
  931. Difference.X = Difference.X + 360
  932. end
  933.  
  934. Difference.Y = Angle2.Y - Angle1.Y
  935.  
  936. if (Difference.Y > 180) then
  937. Difference.Y = Difference.Y - 360
  938. elseif (Difference.Y < -180) then
  939. Difference.Y = Difference.Y + 360
  940. end
  941.  
  942. Difference.Z = Angle2.Z - Angle1.Z
  943.  
  944. if (Difference.Z > 180) then
  945. Difference.Z = Difference.Z - 360
  946. elseif (Difference.Z < -180) then
  947. Difference.Z = Difference.Z + 360
  948. end
  949.  
  950. return Vector3.new(Difference.X, Difference.Y, Difference.Z)
  951. end
  952.  
  953. local draggingBlock = nil
  954. function makeInventory()
  955. local playerGui = player:FindFirstChild("PlayerGui")
  956. if playerGui then
  957. local invGui = Instance.new("ScreenGui", playerGui)
  958. local creativeInv = Instance.new("Frame", invGui)
  959. creativeInv.BackgroundTransparency = 1
  960. creativeInv.Position = UDim2.new(0.5, -170, 0.5, -202)
  961.  
  962. creativeInv.Visible = false
  963.  
  964. -- creative inventory GUI...
  965.  
  966. local blackOut = makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(1, 0, 1, 0),
  967. Color3.new(0/255, 0/255, 0/255), 0.3, invGui, 1)
  968. blackOut.Visible = false
  969.  
  970. creativeInv.Changed:connect(function()
  971. blackOut.Visible = creativeInv.Visible
  972. end)
  973.  
  974. local changeLog = Instance.new("TextLabel", invGui)
  975. changeLog.Text = Changelog
  976. changeLog.Font = "SourceSans"
  977. changeLog.FontSize = Enum.FontSize.Size12
  978. changeLog.Size = UDim2.new(0, changeLog.TextBounds.X, 0, changeLog.TextBounds.Y + 2)
  979. changeLog.BackgroundColor3 = Color3.new(0, 0, 0)
  980. changeLog.BorderSizePixel = 0
  981. changeLog.BackgroundTransparency = 0.5
  982. changeLog.Position = UDim2.new(0.5, -changeLog.Size.X.Offset/2, 0.5, -changeLog.Size.Y.Offset/2)
  983. changeLog.TextColor3 = Color3.new(1, 1, 1)
  984. changeLog.TextXAlignment = "Left"
  985. changeLog.TextYAlignment = "Top"
  986.  
  987. local coolButton = Instance.new("TextButton", changeLog)
  988. coolButton.Position = UDim2.new(1, -17, 0, 1)
  989. coolButton.Size = UDim2.new(0, 16, 0, 12)
  990. coolButton.Text = "X"
  991. coolButton.Font = "SourceSans"
  992. coolButton.FontSize = Enum.FontSize.Size12
  993. coolButton.BorderSizePixel = 0
  994. coolButton.BackgroundColor3 = Color3.new(1, 0, 0)
  995. coolButton.BackgroundTransparency = 0.2
  996. coolButton.TextColor3 = Color3.new(1, 1, 1)
  997. coolButton.TextStrokeTransparency = 0.5
  998. coolButton.ZIndex = 2
  999.  
  1000. local line = makeSquare(UDim2.new(0, 0, 1, -14), UDim2.new(1, 0, 0, 14),
  1001. Color3.new(0, 0, 0), 0.75, changeLog, 2)
  1002.  
  1003. local line2 = makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(1, 0, 0, 14),
  1004. Color3.new(1, 1, 1), 0.9, changeLog, 1)
  1005.  
  1006. line2.Text = "Change Log"
  1007. line2.TextColor3 = Color3.new(1, 1, 1)
  1008. line2.TextStrokeTransparency = 0.75
  1009. line2.Font = "SourceSans"
  1010. line2.FontSize = Enum.FontSize.Size12
  1011.  
  1012. line.Text = "Made by Depr1"
  1013. line.TextColor3 = Color3.new(1, 0.65, 0)
  1014. line.TextStrokeTransparency = 0.5
  1015. line.Font = "SourceSans"
  1016. line.FontSize = Enum.FontSize.Size14
  1017. line.TextXAlignment = "Left"
  1018.  
  1019. coolButton.MouseButton1Click:connect(function()
  1020. changeLog.Visible = false
  1021. end)
  1022.  
  1023. makeSquare(UDim2.new(0, -2, 0, 2), UDim2.new(0, 340, 0, 404),
  1024. Color3.new(198/255, 198/255, 198/255), 0, creativeInv, 3)
  1025. makeSquare(UDim2.new(0, 338, 0, 0), UDim2.new(0, 6, 0, 406),
  1026. Color3.new(85/255, 85/255, 85/255), 0, creativeInv, 2)
  1027. makeSquare(UDim2.new(0, 0, 0, 404), UDim2.new(0, 342, 0, 4),
  1028. Color3.new(85/255, 85/255, 85/255), 0, creativeInv, 3)
  1029. makeSquare(UDim2.new(0, 2, 0, 0), UDim2.new(0, 338, 0, 402),
  1030. Color3.new(198/255, 198/255, 198/255), 0, creativeInv, 3)
  1031. makeSquare(UDim2.new(0, -4, 0, -2), UDim2.new(0, 4, 0, 406),
  1032. Color3.new(255/255, 255/255, 255/255), 0, creativeInv, 3)
  1033. makeSquare(UDim2.new(0, -2, 0, -4), UDim2.new(0, 342, 0, 6),
  1034. Color3.new(255/255, 255/255, 255/255), 0, creativeInv, 2)
  1035. makeSquare(UDim2.new(0, 340, 0, -2), UDim2.new(0, 2, 0, 2),
  1036. Color3.new(198/255, 198/255, 198/255), 0, creativeInv, 2)
  1037. makeSquare(UDim2.new(0, 340, 0, -4), UDim2.new(0, 2, 0, 4),
  1038. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1039. makeSquare(UDim2.new(0, 342, 0, -2), UDim2.new(0, 2, 0, 2),
  1040. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1041. makeSquare(UDim2.new(0, 344, 0, 0), UDim2.new(0, 2, 0, 406),
  1042. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1043. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 2, 0, 4),
  1044. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1045. makeSquare(UDim2.new(0, -2, 0, -6), UDim2.new(0, 342, 0, 4),
  1046. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1047. makeSquare(UDim2.new(0, 0, 0, 406), UDim2.new(0, 342, 0, 4),
  1048. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1049. makeSquare(UDim2.new(0, 342, 0, 404), UDim2.new(0, 2, 0, 4),
  1050. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1051. makeSquare(UDim2.new(0, -4, 0, 404), UDim2.new(0, 2, 0, 2),
  1052. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1053. makeSquare(UDim2.new(0, -2, 0, 406), UDim2.new(0, 2, 0, 2),
  1054. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1055. makeSquare(UDim2.new(0, -6, 0, -2), UDim2.new(0, 2, 0, 406),
  1056. Color3.new(0/255, 0/255, 0/255), 0, creativeInv, 1)
  1057. local text = makeSquare(UDim2.new(0, 4, 0, 8), UDim2.new(0, 0, 0, 0), Color3.new(0/255, 0/255, 0/255), 1, creativeInv, 3)
  1058. text.Text = "Creative Inventory"
  1059. text.Font = "SourceSansSemibold"
  1060. text.TextSize = 14
  1061. text.TextXAlignment = "Left"
  1062. --
  1063. local draggingBlockPicture = Instance.new("ImageLabel", invGui)
  1064. draggingBlockPicture.BackgroundTransparency = 1
  1065. draggingBlockPicture.Size = UDim2.new(0, 32, 0, 32)
  1066. draggingBlockPicture.ZIndex = 5
  1067. coroutine.resume(coroutine.create(function()
  1068. local invMouse = player:GetMouse()
  1069. --local RS = game:GetService("RunService").RenderStepped
  1070. invMouse.Button2Down:connect(function()
  1071. draggingBlock = nil
  1072. end)
  1073. while RS:wait() do
  1074. draggingBlockPicture.Position = UDim2.new(0, invMouse.X - 16, 0, invMouse.Y - 16)
  1075. if draggingBlock ~= nil then
  1076. draggingBlockPicture.Image = draggingBlock.frontTex
  1077. else
  1078. draggingBlockPicture.Image = ""
  1079. end
  1080. end
  1081. end))
  1082.  
  1083. local done = false
  1084. local x = 0
  1085. local y = 0
  1086.  
  1087. for i,b in pairs(creativeInventory) do
  1088. local display = ""
  1089. if b.displayTex == "" then
  1090. display = b.frontTex
  1091. else
  1092. if b.displayTex then
  1093. display = b.displayTex
  1094. end
  1095. end
  1096. putInventorySlot(UDim2.new(0.5, (x*36) + 8, 0.5, (y*36) + 28), display, creativeInv, 4).MouseButton1Down:connect(function()
  1097. if draggingBlock == nil then
  1098. draggingBlock = b
  1099. end
  1100. end)
  1101. x = x + 1
  1102. if x >= 8 then
  1103. x = 0
  1104. y = y + 1
  1105. end
  1106. end
  1107. if x == 0 then done = true end
  1108. while x < 8 and done == false do
  1109. putInventorySlot(UDim2.new(0.5, (x*36) + 8, 0.5, (y*36) + 28), "", creativeInv, 4)
  1110. x = x + 1
  1111. end
  1112. for i = 1, 9 do
  1113. if toolBar[i] ~= nil then
  1114. local invSlot = putInventorySlot(UDim2.new(0, 8 + ((i-1)*36), 0, 360), toolBar[i].frontTex, creativeInv, 4)
  1115. invSlot.MouseButton2Down:connect(function()
  1116. local imgLabel = invSlot:FindFirstChild("ImageLabel")
  1117. if imgLabel then
  1118. toolBar[i] = nil
  1119. imgLabel.Image = ""
  1120. end
  1121. end)
  1122. invSlot.MouseButton1Down:connect(function()
  1123. --updateHand = true
  1124. local imgLabel = invSlot:FindFirstChild("ImageLabel")
  1125. if toolBar[i] == nil then
  1126. toolBar[i] = draggingBlock
  1127. imgLabel.Image = draggingBlock.frontTex
  1128. draggingBlock = nil
  1129. return
  1130. end
  1131. if toolBar[i] ~= nil and draggingBlock == nil then
  1132. draggingBlock = toolBar[i]
  1133. toolBar[i] = nil
  1134. imgLabel.Image = ""
  1135. return
  1136. elseif toolBar[i] ~= nil and draggingBlock ~= nil then
  1137. --draggingBlock = toolBar[i]
  1138. --toolBar[i] = nil
  1139. imgLabel.Image = ""
  1140. local temp = toolBar[i]
  1141. toolBar[i] = draggingBlock
  1142. if imgLabel and draggingBlock ~= nil then
  1143. imgLabel.Image = draggingBlock.frontTex
  1144. end
  1145. if imgLabel and draggingBlock == nil then
  1146. imgLabel.Image = ""
  1147. end
  1148. draggingBlock = temp
  1149. return
  1150. end
  1151. end)
  1152. else
  1153. local invSlot = putInventorySlot(UDim2.new(0, 8 + ((i-1)*36), 0, 360), "", creativeInv, 4)
  1154. invSlot.MouseButton2Down:connect(function()
  1155. local imgLabel = invSlot:FindFirstChild("ImageLabel")
  1156. if imgLabel then
  1157. toolBar[i] = nil
  1158. imgLabel.Image = ""
  1159. end
  1160. end)
  1161. invSlot.MouseButton1Down:connect(function()
  1162. --updateHand = true
  1163. local imgLabel = invSlot:FindFirstChild("ImageLabel")
  1164. if toolBar[i] == nil then
  1165. toolBar[i] = draggingBlock
  1166. imgLabel.Image = draggingBlock.frontTex
  1167. draggingBlock = nil
  1168. return
  1169. end
  1170. if toolBar[i] ~= nil and draggingBlock == nil then
  1171. draggingBlock = toolBar[i]
  1172. toolBar[i] = nil
  1173. imgLabel.Image = ""
  1174. return
  1175. elseif toolBar[i] ~= nil and draggingBlock ~= nil then
  1176. --draggingBlock = toolBar[i]
  1177. --toolBar[i] = nil
  1178. imgLabel.Image = ""
  1179. local temp = toolBar[i]
  1180. toolBar[i] = draggingBlock
  1181. if imgLabel and draggingBlock ~= nil then
  1182. imgLabel.Image = draggingBlock.frontTex
  1183. end
  1184. if imgLabel and draggingBlock == nil then
  1185. imgLabel.Image = ""
  1186. end
  1187. draggingBlock = temp
  1188. return
  1189. end
  1190. end)
  1191. end
  1192. end
  1193. return creativeInv
  1194. end
  1195. end
  1196. function putToolBarSlot(position, image, zindex)
  1197. local playerGui = player:FindFirstChild("PlayerGui")
  1198. if playerGui then
  1199. local gui = playerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", playerGui)
  1200. gui.Name = "ToolBar"
  1201. local slot = Instance.new("ImageLabel", gui)
  1202. slot.Position = position
  1203. slot.Size = UDim2.new(0, 32, 0, 32)
  1204. slot.BackgroundTransparency = 1
  1205. slot.ImageTransparency = 0
  1206. slot.Image = image
  1207. slot.ZIndex = 2
  1208.  
  1209. local imgSlot = makeImage(UDim2.new(0, 0, 0, 0), UDim2.new(0, 32, 0, 32),
  1210. "rbxassetid://347007448", slot)
  1211.  
  1212. imgSlot.ImageTransparency = 0.25
  1213. imgSlot.BackgroundTransparency = 1
  1214. imgSlot.ImageColor3 = Color3.new(0.225, 0.225, 0.225)
  1215.  
  1216. makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 2, 0, 32),
  1217. Color3.new(0/255, 0/255, 0/255), 0.7, slot)
  1218. makeSquare(UDim2.new(0, 2, 0, 0), UDim2.new(0, 30, 0, 2),
  1219. Color3.new(0/255, 0/255, 0/255), 0.7, slot)
  1220. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 36, 0, 2),
  1221. Color3.new(106/255, 106/255, 106/255), 0, slot)
  1222. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 2, 0, 36),
  1223. Color3.new(106/255, 106/255, 106/255), 0, slot)
  1224. makeSquare(UDim2.new(0, 0, 0, 32), UDim2.new(0, 34, 0, 2),
  1225. Color3.new(130/255, 130/255, 130/255), 0, slot)
  1226. makeSquare(UDim2.new(0, 32, 0, 0), UDim2.new(0, 2, 0, 34),
  1227. Color3.new(130/255, 130/255, 130/255), 0, slot)
  1228. makeSquare(UDim2.new(0, -4, 0, -2), UDim2.new(0, 2, 0, 38),
  1229. Color3.new(130/255, 130/255, 130/255), 0, slot)
  1230. makeSquare(UDim2.new(0, 34, 0, -2), UDim2.new(0, 2, 0, 36),
  1231. Color3.new(106/255, 106/255, 106/255), 0, slot)
  1232. makeSquare(UDim2.new(0, -2, 0, 34), UDim2.new(0, 38, 0, 2),
  1233. Color3.new(106/255, 106/255, 106/255), 0, slot)
  1234. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 40, 0, 2),
  1235. Color3.new(156/255, 156/255, 156/255), 0, slot)
  1236. return slot
  1237. end
  1238. end
  1239. function divide(x, d)
  1240. if x ~= 0 and d ~= 0 then
  1241. return x/d
  1242. else
  1243. return x
  1244. end
  1245. end -- so it doesn't divide by zero
  1246. function getDistance(v1, v2)
  1247. return math.abs((Vector3.new(math.abs(v2.X - v1.X), math.abs(v2.Y - v1.Y), math.abs(v2.Z - v1.Z))).Magnitude)
  1248. end
  1249. function SnapToGrid(x, gridX)
  1250. local x = math.floor((x / gridX) + 0.5) * gridX
  1251. return x
  1252. end
  1253. function round(x)
  1254. if x%2 ~= 0.5 then
  1255. return math.floor(x+0.5)
  1256. end
  1257. return x-0.5
  1258. end
  1259. function weldTo(part1, part2)
  1260. local weld = Instance.new("Weld", part1)
  1261. weld.Part0 = part1
  1262. weld.Part1 = part2
  1263. return weld
  1264. end
  1265. function getMagnitudeXZ(velocity)
  1266. return math.sqrt(math.abs(velocity.X)^2 + math.abs(velocity.Z)^2)
  1267. end
  1268. function findHumanoid(inst)
  1269. local find = inst
  1270. local hum = nil
  1271. repeat
  1272. if find.Name == "Workspace" then return nil end
  1273. find = find.Parent
  1274. hum = find:FindFirstChild("Humanoid")
  1275. until hum
  1276. --if hum then print("found!!") else print("aw... not found") end
  1277. --if hum.ClassName ~= "Humanoid" then hum = nil end
  1278. return hum
  1279. end
  1280. function getSideByLocation(loc)
  1281. local side = nil
  1282. if loc.X < 0 then side = "Left" end
  1283. if loc.X > 0 then side = "Right" end
  1284. if loc.Y > 0 then side = "Top" end
  1285. if loc.Y < 0 then side = "Bottom" end
  1286. if loc.Z < 0 then side = "Front" end
  1287. if loc.Z > 0 then side = "Back" end
  1288.  
  1289. if (math.abs(loc.X) > 0 and math.abs(loc.Y) > 0) or
  1290. (math.abs(loc.X) > 0 and math.abs(loc.Z) > 0) or
  1291. (math.abs(loc.Y) > 0 and math.abs(loc.Z) > 0)
  1292. then
  1293. return nil
  1294. end
  1295. return side
  1296. end
  1297. function getSideByLocationRedstone(loc)
  1298. local side = nil
  1299. if loc.X < 0 then side = "Left" end
  1300. if loc.X > 0 then side = "Right" end
  1301. if loc.Y > 0 then side = "Top" end
  1302. if loc.Y < 0 then side = "Bottom" end
  1303. if loc.Z < 0 then side = "Front" end
  1304. if loc.Z > 0 then side = "Back" end
  1305.  
  1306. if (math.abs(loc.X) > 0 and math.abs(loc.Y) > 0) or
  1307. (math.abs(loc.X) > 0 and math.abs(loc.Z) > 0) or
  1308. (math.abs(loc.Y) > 0 and math.abs(loc.Z) > 0)
  1309. then
  1310. return nil
  1311. end
  1312. return side
  1313. end
  1314. function getBlockAtRegion(region)
  1315. local blockFound = nil
  1316. for _,part in pairs(game.Workspace:FindPartsInRegion3(region, nil, math.huge)) do
  1317. local usePart = true
  1318. if part.Name == "Debris" then usePart = false end
  1319. if usePart == true then
  1320. blockFound = part
  1321. break
  1322. end
  1323. end
  1324. return blockFound
  1325. end
  1326. function getRedstoneAtRegion(region)
  1327. local blockFound = nil
  1328. for _,part in pairs(game.Workspace:FindPartsInRegion3(region, nil, math.huge)) do
  1329. if isRedstone(part) then
  1330. blockFound = part
  1331. break
  1332. end
  1333. end
  1334. return blockFound
  1335. end
  1336. function isRedstone(block)
  1337. local objType = block:FindFirstChild("ObjectType")
  1338. if objType then
  1339. if objType.Value == "Redstone Dust" then
  1340. return true
  1341. else
  1342. return false
  1343. end
  1344. end
  1345. end
  1346. function updateRedstoneDust(dust, leftBlk, rightBlk, topBlk, bottomBlk, frontBlk, backBlk, recursion)
  1347. local objType = nil
  1348. if dust then
  1349. objType = dust:FindFirstChild("ObjectType")
  1350. end
  1351.  
  1352. local redstoneDust = "rbxassetid://151911305"
  1353. local redstoneLine = "rbxassetid://151907047"
  1354. local redstoneCorner = "rbxassetid://151907106"
  1355. local redstoneT = "rbxassetid://151907156"
  1356. local redstoneCross = "rbxassetid://151906997"
  1357.  
  1358. local Rotation = 0
  1359.  
  1360. local theresRedstoneAtLeft = false
  1361. local theresRedstoneAtRight = false
  1362. local theresRedstoneAtFront = false
  1363. local theresRedstoneAtBack = false
  1364.  
  1365. if leftBlk then theresRedstoneAtLeft = isRedstone(leftBlk) end
  1366. if rightBlk then theresRedstoneAtRight = isRedstone(rightBlk) end
  1367. if frontBlk then theresRedstoneAtFront = isRedstone(frontBlk) end
  1368. if backBlk then theresRedstoneAtBack = isRedstone(backBlk) end
  1369.  
  1370. if objType then
  1371. if objType.Value == "Redstone Dust" then
  1372. local topDecal = dust:FindFirstChild("Top")
  1373. if topDecal then
  1374. if theresRedstoneAtBack == false and theresRedstoneAtFront == false and
  1375. theresRedstoneAtLeft == false and theresRedstoneAtRight == false then
  1376. topDecal.Texture = redstoneDust
  1377. Rotation = 0
  1378. end
  1379.  
  1380. if theresRedstoneAtLeft == true or theresRedstoneAtRight == true then
  1381. topDecal.Texture = redstoneLine
  1382. Rotation = 0
  1383. end
  1384.  
  1385. if theresRedstoneAtFront == true or theresRedstoneAtBack == true then
  1386. topDecal.Texture = redstoneLine
  1387. Rotation = 90
  1388. end
  1389.  
  1390. if theresRedstoneAtLeft == true and theresRedstoneAtBack == true then
  1391. topDecal.Texture = redstoneCorner
  1392. Rotation = 0
  1393. end
  1394.  
  1395. if theresRedstoneAtBack == true and theresRedstoneAtRight == true then
  1396. topDecal.Texture = redstoneCorner
  1397. Rotation = 90
  1398. end
  1399.  
  1400. if theresRedstoneAtRight == true and theresRedstoneAtFront == true then
  1401. topDecal.Texture = redstoneCorner
  1402. Rotation = 180
  1403. end
  1404.  
  1405. if theresRedstoneAtFront == true and theresRedstoneAtLeft == true then
  1406. topDecal.Texture = redstoneCorner
  1407. Rotation = -90
  1408. end
  1409.  
  1410. if theresRedstoneAtBack == true and theresRedstoneAtLeft == true
  1411. and theresRedstoneAtFront == true then
  1412. topDecal.Texture = redstoneT
  1413. Rotation = -90
  1414. end
  1415.  
  1416. if theresRedstoneAtLeft == true and theresRedstoneAtFront == true
  1417. and theresRedstoneAtRight == true then
  1418. topDecal.Texture = redstoneT
  1419. Rotation = -180
  1420. end
  1421.  
  1422. if theresRedstoneAtFront == true and theresRedstoneAtRight == true
  1423. and theresRedstoneAtBack == true then
  1424. topDecal.Texture = redstoneT
  1425. Rotation = 90
  1426. end
  1427.  
  1428. if theresRedstoneAtRight == true and theresRedstoneAtBack == true
  1429. and theresRedstoneAtLeft == true then
  1430. topDecal.Texture = redstoneT
  1431. Rotation = 0
  1432. end
  1433.  
  1434. if theresRedstoneAtLeft == true and theresRedstoneAtRight == true and
  1435. theresRedstoneAtFront == true and theresRedstoneAtBack == true then
  1436. topDecal.Texture = redstoneCross
  1437. Rotation = 0
  1438. end
  1439. end
  1440. else
  1441. error("Not redstone dust.")
  1442. end
  1443. end
  1444.  
  1445. if recursion == true then
  1446. local function updateTex(blockTarget)
  1447. local leftSide = nil
  1448. local rightSide = nil
  1449. local frontSide = nil
  1450. local backSide = nil
  1451.  
  1452. local Point1 = blockTarget.CFrame.p - Vector3.new(2.6, 0.1, 2.6)
  1453. local Point2 = blockTarget.CFrame.p + Vector3.new(2.6, 0.1, 2.6)
  1454. local Region = Region3.new(Point1, Point2)
  1455. for _,part in pairs(game.Workspace:FindPartsInRegion3(
  1456. Region,
  1457. nil,
  1458. math.huge
  1459. )) do
  1460. local objType = part:FindFirstChild("ObjectType")
  1461. if isRedstone(part) then
  1462. local side = getSideByLocationRedstone(blockTarget.CFrame.p - part.CFrame.p)
  1463. if side == "Left" then
  1464. leftSide = part
  1465. elseif side == "Right" then
  1466. rightSide = part
  1467. elseif side == "Front" then
  1468. frontSide = part
  1469. elseif side == "Back" then
  1470. backSide = part
  1471. elseif side == "Left Top" then
  1472. leftSide = part
  1473. elseif side == "Right Top" then
  1474. rightSide = part
  1475. elseif side == "Front Top" then
  1476. frontSide = part
  1477. elseif side == "Back Top" then
  1478. backSide = part
  1479. elseif side == "Left Bottom" then
  1480. leftSide = part
  1481. elseif side == "Right Bottom" then
  1482. rightSide = part
  1483. elseif side == "Front Bottom" then
  1484. frontSide = part
  1485. elseif side == "Back Bottom" then
  1486. backSide = part
  1487. end
  1488. end
  1489. end
  1490.  
  1491. updateRedstoneDust(blockTarget, leftSide, rightSide, nil, nil, frontSide, backSide, false)
  1492. end
  1493. if leftBlk and theresRedstoneAtLeft then updateTex(leftBlk) end
  1494. if rightBlk and theresRedstoneAtRight then updateTex(rightBlk) end
  1495. if frontBlk and theresRedstoneAtFront then updateTex(frontBlk) end
  1496. if backBlk and theresRedstoneAtBack then updateTex(backBlk) end
  1497. end
  1498.  
  1499. if dust then dust.CFrame = CFrame.new(dust.CFrame.p.X, dust.CFrame.p.Y, dust.CFrame.p.Z) * CFrame.Angles(0, math.rad(Rotation), 0) end
  1500. end
  1501. function placeBlock(block, cFPos, Mouse)
  1502. if block == nil then
  1503. if Mouse.Target.Size.X <= 10 and Mouse.Target.Size.Y <= 10 and Mouse.Target.Size.Z <= 10 and Mouse.Target then
  1504. if Mouse.Target.Parent.Name ~= "Camera" then
  1505. --print(Mouse.Target:GetFullName())
  1506. local blkTar = Mouse.Target
  1507. --Mouse.Target.Parent = nil
  1508. local blockIsRedstone = isRedstone(blkTar)
  1509.  
  1510. local Point1 = blkTar.CFrame.p - Vector3.new(2.7, 2.7, 2.7)
  1511. local Point2 = blkTar.CFrame.p + Vector3.new(2.7, 2.7, 2.7)
  1512. local Region = Region3.new(Point1, Point2)
  1513. for _,part in pairs(game.Workspace:FindPartsInRegion3(
  1514. Region,
  1515. nil,
  1516. math.huge
  1517. )) do
  1518.  
  1519. if part:FindFirstChild("IsBlock") then
  1520. local side1 = getSideByLocation(blkTar.CFrame.p - part.CFrame.p)
  1521. if getSideByLocation(blkTar.CFrame.p - part.CFrame.p) then
  1522. local texture = part:FindFirstChild(side1)
  1523. if texture then
  1524. texture.Transparency = 0
  1525. end
  1526. end
  1527. end
  1528. end
  1529.  
  1530. for i = 1, 9 do
  1531. local part = Instance.new("Part", workspace)
  1532. part.Size = Vector3.new(0, 0, 0)
  1533. part.Transparency = 1
  1534. part.CanCollide = false
  1535. part.Velocity = Vector3.new(math.random(-5, 5), 5, math.random(-5, 5))
  1536. part.Name = "Debris"
  1537.  
  1538. part.CFrame =
  1539. Mouse.Target.CFrame *
  1540. CFrame.new(math.random(-blkTar.Size.X/2, blkTar.Size.X/2), math.random(-blkTar.Size.Y/2, blkTar.Size.Y/2), math.random(-blkTar.Size.Z/2, blkTar.Size.Z/2))
  1541.  
  1542. part.CustomPhysicalProperties = PhysicalProperties.new(0, 0.2, 0, 100, 100)
  1543.  
  1544. local billboard = Instance.new("BillboardGui", part)
  1545. billboard.Size = UDim2.new(1.2, 0, 1.2, 0)
  1546.  
  1547. local clipDescendant = Instance.new("TextLabel", billboard)
  1548. clipDescendant.Size = UDim2.new(0.5, 0, 0.5, 0)
  1549. clipDescendant.BackgroundTransparency = 1
  1550. clipDescendant.Text = ""
  1551. clipDescendant.ClipsDescendants = true
  1552.  
  1553. local img = Instance.new("ImageLabel", clipDescendant)
  1554. img.Size = UDim2.new(2, 0, 2, 0)
  1555. img.BackgroundTransparency = 1
  1556. img.Position = UDim2.new(math.random(-70, 70)/100, 0, math.random(-70, 70)/100, 0)
  1557.  
  1558. local tex = blkTar:FindFirstChild("Front")
  1559. if tex then
  1560. img.Image = tex.Texture
  1561. else
  1562. img.Image = "rbxassetid://744949545"
  1563. end
  1564.  
  1565. if img.Image == "rbxassetid://744949545" then
  1566. img.ImageColor3 = blkTar.Color
  1567. end
  1568.  
  1569. part.Touched:connect(function(prt)
  1570. if prt ~= blkTar then
  1571. part.CanCollide = true
  1572. end
  1573. end)
  1574.  
  1575. coroutine.resume(coroutine.create(function()
  1576. wait(math.random(50, 65)/100)
  1577. part:Destroy()
  1578. end))
  1579. --part.Anchored = false
  1580. end
  1581. blkTar:Destroy()
  1582. if blockIsRedstone == true then
  1583. local leftSide = nil
  1584. local rightSide = nil
  1585. local frontSide = nil
  1586. local backSide = nil
  1587.  
  1588. local Point1 = blkTar.CFrame.p - Vector3.new(2.6, 0.1, 2.6)
  1589. local Point2 = blkTar.CFrame.p + Vector3.new(2.6, 0.1, 2.6)
  1590. local Region = Region3.new(Point1, Point2)
  1591. for _,part in pairs(game.Workspace:FindPartsInRegion3(
  1592. Region,
  1593. nil,
  1594. math.huge
  1595. )) do
  1596. local objType = part:FindFirstChild("ObjectType")
  1597. if isRedstone(part) then
  1598. local side = getSideByLocationRedstone(blkTar.CFrame.p - part.CFrame.p)
  1599. if side == "Left" then
  1600. leftSide = part
  1601. elseif side == "Right" then
  1602. rightSide = part
  1603. elseif side == "Front" then
  1604. frontSide = part
  1605. elseif side == "Back" then
  1606. backSide = part
  1607. elseif side == "Left Top" then
  1608. leftSide = part
  1609. elseif side == "Right Top" then
  1610. rightSide = part
  1611. elseif side == "Front Top" then
  1612. frontSide = part
  1613. elseif side == "Back Top" then
  1614. backSide = part
  1615. elseif side == "Left Bottom" then
  1616. leftSide = part
  1617. elseif side == "Right Bottom" then
  1618. rightSide = part
  1619. elseif side == "Front Bottom" then
  1620. frontSide = part
  1621. elseif side == "Back Bottom" then
  1622. backSide = part
  1623. end
  1624. end
  1625. end
  1626.  
  1627. updateRedstoneDust(nil, leftSide, rightSide, nil, nil, frontSide, backSide, true)
  1628. end
  1629. end
  1630. end
  1631. return nil
  1632. else
  1633. local blkMouseTarget = Mouse.Target
  1634.  
  1635. local blockPlaced = Instance.new("Part", workspace)
  1636. blockPlaced.Material = "Fabric"
  1637. blockPlaced.Transparency = block.transparency
  1638. blockPlaced.Anchored = true
  1639. blockPlaced.Size = block.size
  1640.  
  1641. blockPlaced.CFrame = cFPos
  1642.  
  1643. local blockType = Instance.new("StringValue", blockPlaced)
  1644. blockType.Name = "ObjectType"
  1645. blockType.Value = block.objectType
  1646.  
  1647. blockPlaced.Name = block.name
  1648. putTexture(blockPlaced, block.frontTex, block.backTex,
  1649. block.topTex, block.bottomTex, block.leftTex, block.rightTex, "Texture")
  1650.  
  1651. if block.objectType == "Slab" then
  1652. blockPlaced.Size = blockPlaced.Size / Vector3.new(1, 2, 1)
  1653. blockPlaced.CFrame = blockPlaced.CFrame * CFrame.new(0, -blockPlaced.Size.Y/2, 0)
  1654. elseif block.objectType == "Redstone Dust" then
  1655. blockPlaced.CFrame = blockPlaced.CFrame * CFrame.new(0, -1.3, 0)
  1656. blockPlaced.CanCollide = false
  1657.  
  1658. local canPlace = false
  1659.  
  1660. if isRedstone(blkMouseTarget) == true then
  1661. blockPlaced:Destroy()
  1662. return
  1663. end
  1664.  
  1665. local partBelow = getBlockAtRegion(Region3.new(
  1666. blockPlaced.CFrame.p - Vector3.new(1, 1, 1),
  1667. blockPlaced.CFrame.p + Vector3.new(1, 1, 1)
  1668. ))
  1669.  
  1670. if partBelow then
  1671. local targetObjType = partBelow:FindFirstChild("ObjectType")
  1672. if targetObjType then
  1673. if targetObjType.Value == "Block" then
  1674. canPlace = true
  1675. end
  1676. end
  1677. end
  1678.  
  1679. if canPlace == false then
  1680. blockPlaced:Destroy()
  1681. return
  1682. end
  1683.  
  1684. local leftSide = nil
  1685. local rightSide = nil
  1686. local frontSide = nil
  1687. local backSide = nil
  1688.  
  1689. local Point1 = blockPlaced.CFrame.p - Vector3.new(2.6, 0.1, 2.6)
  1690. local Point2 = blockPlaced.CFrame.p + Vector3.new(2.6, 0.1, 2.6)
  1691. local Region = Region3.new(Point1, Point2)
  1692. for _,part in pairs(game.Workspace:FindPartsInRegion3(
  1693. Region,
  1694. nil,
  1695. math.huge
  1696. )) do
  1697. local objType = part:FindFirstChild("ObjectType")
  1698. if isRedstone(part) then
  1699.  
  1700. local side = getSideByLocationRedstone(blockPlaced.CFrame.p - part.CFrame.p)
  1701. if side == "Left" then
  1702. leftSide = part
  1703. elseif side == "Right" then
  1704. rightSide = part
  1705. elseif side == "Front" then
  1706. frontSide = part
  1707. elseif side == "Back" then
  1708. backSide = part
  1709. elseif side == "Left Top" then
  1710. leftSide = part
  1711. elseif side == "Right Top" then
  1712. rightSide = part
  1713. elseif side == "Front Top" then
  1714. frontSide = part
  1715. elseif side == "Back Top" then
  1716. backSide = part
  1717. elseif side == "Left Bottom" then
  1718. leftSide = part
  1719. elseif side == "Right Bottom" then
  1720. rightSide = part
  1721. elseif side == "Front Bottom" then
  1722. frontSide = part
  1723. elseif side == "Back Bottom" then
  1724. backSide = part
  1725. end
  1726.  
  1727.  
  1728. --if getSideByLocation(cFPos.p - part.CFrame.p) then
  1729. -- local texture = part:FindFirstChild(side1)
  1730. -- if texture then
  1731. -- texture.Transparency = 1
  1732. -- end
  1733. --end
  1734. --[[local side2 = getSideByLocation(part.CFrame.p - cFPos.p)
  1735. if getSideByLocation(cFPos.p - part.CFrame.p) then
  1736. local texture = blockPlaced:FindFirstChild(side2)
  1737. if texture then
  1738. texture.Transparency = 1
  1739. end
  1740. end]]
  1741. end
  1742. end
  1743.  
  1744. updateRedstoneDust(blockPlaced, leftSide, rightSide, nil, nil, frontSide, backSide, true)
  1745.  
  1746. --local partBelow = getBlockAtRegion(Region3.new(
  1747. -- blockPlaced.CFrame.p - Vector3.new(1, 1, 1),
  1748. -- blockPlaced.CFrame.p + Vector3.new(1, 1, 1)
  1749. --))
  1750. end
  1751.  
  1752. if Mouse.Target.Name == block.name then
  1753. local targetObjType = Mouse.Target:FindFirstChild("ObjectType")
  1754. if targetObjType then
  1755. if targetObjType.Value == "Slab" then
  1756. local side = Mouse.TargetSurface.Name --getSideByLocation(Mouse.Target.Position - cFPos.p)
  1757. if side == "Bottom" or side == "Top" then
  1758. Mouse.Target.Size = Mouse.Target.Size * Vector3.new(1, 2, 1)
  1759. Mouse.Target.CFrame = Mouse.Target.CFrame * CFrame.new(0, blockPlaced.Size.Y/2, 0)
  1760.  
  1761. targetObjType.Value = "Block"
  1762.  
  1763. blockPlaced:Destroy()
  1764. return
  1765. end
  1766. end
  1767. end
  1768. end
  1769.  
  1770. local Point1 = cFPos.p - Vector3.new(2.7, 2.7, 2.7)
  1771. local Point2 = cFPos.p + Vector3.new(2.7, 2.7, 2.7)
  1772. local Region = Region3.new(Point1, Point2)
  1773. for _,part in pairs(game.Workspace:FindPartsInRegion3(
  1774. Region,
  1775. nil,
  1776. math.huge
  1777. )) do
  1778. local objType = part:FindFirstChild("ObjectType")
  1779. if part:FindFirstChild("IsBlock") and objType then
  1780. local doNothing = false
  1781. if objType.Value == "Slab" or block.objectType == "Slab" then doNothing = true end
  1782. if part.Name == blockPlaced.Name and doNothing == false then
  1783. local side1 = getSideByLocation(cFPos.p - part.CFrame.p)
  1784. if getSideByLocation(cFPos.p - part.CFrame.p) then
  1785. local texture = part:FindFirstChild(side1)
  1786. if texture then
  1787. texture.Transparency = 1
  1788. end
  1789. end
  1790. local side2 = getSideByLocation(part.CFrame.p - cFPos.p)
  1791. if getSideByLocation(cFPos.p - part.CFrame.p) then
  1792. local texture = blockPlaced:FindFirstChild(side2)
  1793. if texture then
  1794. texture.Transparency = 1
  1795. end
  1796. end
  1797. end
  1798. end
  1799. end
  1800.  
  1801.  
  1802. local isBlock = Instance.new("CFrameValue", blockPlaced)
  1803. isBlock.Name = "IsBlock"
  1804.  
  1805. if block.hasGravity == true then
  1806. local connectedTo = Instance.new("ObjectValue", blockPlaced)
  1807. connectedTo.Name = "ConnectedTo"
  1808. blockPlaced.Anchored = false
  1809. blockPlaced.CanCollide = false
  1810. local detector = Instance.new("Part", workspace:WaitForChild("Camera"))
  1811. detector.Transparency = 1
  1812. detector.CanCollide = false
  1813. detector.Size = Vector3.new(1, 0, 1)
  1814. local weldDetector = Instance.new("Motor6D", detector)
  1815. weldDetector.Part0 = detector
  1816. weldDetector.Part1 = blockPlaced
  1817. weldDetector.C1 = CFrame.new(0, -blockPlaced.Size.Y/2, 0)
  1818. local landed = false
  1819. local function fallingBlock()
  1820. coroutine.resume(coroutine.create(function()
  1821. local falling = blockPlaced:FindFirstChild("IsFalling") or Instance.new("CFrameValue", blockPlaced)
  1822. falling.Name = "IsFalling"
  1823. local grav = 0
  1824. while RS:wait() do
  1825. if landed then falling:Destroy() break end
  1826. grav = math.max(-1, grav - 0.0025)
  1827. --blockPlaced.CFrame = CFrame.new(cFPos.X, blockPlaced.CFrame.Y + grav, cFPos.Z)
  1828. end
  1829. end))
  1830. end
  1831. fallingBlock()
  1832. detector.Touched:connect(function(part)
  1833. if blockPlaced.Anchored == false and part ~= blockPlaced and part.Name ~= "Debris" and part:FindFirstChild("IsFalling") == nil and findHumanoid(part) == nil then
  1834. landed = true
  1835. blockPlaced.CanCollide = true
  1836. blockPlaced.Velocity = Vector3.new(0, 0, 0)
  1837. blockPlaced.Anchored = true
  1838. connectedTo.Value = part
  1839. local yOrigin = part.CFrame.Y + (blockPlaced.Size.Y/2) + (part.Size.Y/2)
  1840. blockPlaced.CFrame = CFrame.new(cFPos.X, yOrigin, cFPos.Z)
  1841. --detector:Destroy()
  1842. local falling = false
  1843. part.Changed:connect(function()
  1844. if part.Position.Y ~= yOrigin and falling == false then
  1845. falling = true
  1846. wait(0.075)
  1847. landed = false
  1848. blockPlaced.Anchored = false
  1849. blockPlaced.CanCollide = false
  1850. blockPlaced.Velocity = Vector3.new(0, 0, 0)
  1851. fallingBlock()
  1852. falling = false
  1853. end
  1854. end)
  1855. workspace.ChildRemoved:connect(function()
  1856. --print("hi")
  1857. if connectedTo.Value.Parent == nil and falling == false then
  1858. falling = true
  1859. landed = false
  1860. blockPlaced.Anchored = false
  1861. blockPlaced.CanCollide = false
  1862. blockPlaced.Velocity = Vector3.new(0, 0, 0)
  1863. fallingBlock()
  1864. end
  1865. end)
  1866. end
  1867. end)
  1868. end
  1869.  
  1870. local blockSound = Instance.new("Sound", blockPlaced)
  1871. blockSound.SoundId = block.sound
  1872. blockSound.Volume = block.soundVol
  1873. blockSound.Pitch = math.random(95, 105)/100
  1874. blockSound.PlayOnRemove = true
  1875. blockSound:Play()
  1876. return blockPlaced
  1877. end
  1878. end
  1879. if player then
  1880. local char = player.Character
  1881. if char then
  1882. for _,cM in pairs(char:GetChildren()) do
  1883. if cM.ClassName == "CharacterMesh" then cM:Destroy() end
  1884. end
  1885.  
  1886. --[]
  1887. local gui = player.PlayerGui:FindFirstChild("ToolBar") or Instance.new("ScreenGui", player.PlayerGui)
  1888. gui.Name = "ToolBar"
  1889.  
  1890. makeSquare(UDim2.new(0.5, -166, 1, -111), UDim2.new(0, 364, 0, 2),
  1891. Color3.new(0/255, 0/255, 0/255), 0, gui)
  1892. makeSquare(UDim2.new(0.5, -166, 1, -111 + 42), UDim2.new(0, 364, 0, 2),
  1893. Color3.new(0/255, 0/255, 0/255), 0, gui)
  1894. makeSquare(UDim2.new(0.5, -166, 1, -111), UDim2.new(0, 2, 0, 44),
  1895. Color3.new(0/255, 0/255, 0/255), 0, gui)
  1896. makeSquare(UDim2.new(0.5, -166 + 362, 1, -111), UDim2.new(0, 2, 0, 44),
  1897. Color3.new(0/255, 0/255, 0/255), 0, gui)
  1898.  
  1899. for i = 1, 9 do
  1900. if toolBar[i] ~= nil then
  1901. local img = putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), toolBar[i].frontTex)
  1902. coroutine.resume(coroutine.create(function()
  1903. while wait() do
  1904. if toolBar[i] ~= nil then
  1905. if toolBar[i].displayTex == "" then
  1906. img.Image = toolBar[i].frontTex
  1907. else
  1908. img.Image = toolBar[i].displayTex
  1909. end
  1910. else
  1911. img.Image = ""
  1912. end
  1913. end
  1914. end))
  1915. else
  1916. local img = putToolBarSlot(UDim2.new(0.5, -160 + ((i-1)*40), 1, -105), "")
  1917. coroutine.resume(coroutine.create(function()
  1918. while wait() do
  1919. if toolBar[i] ~= nil then
  1920. if toolBar[i].displayTex == "" then
  1921. img.Image = toolBar[i].frontTex
  1922. else
  1923. img.Image = toolBar[i].displayTex
  1924. end
  1925. else
  1926. img.Image = ""
  1927. end
  1928. end
  1929. end))
  1930. end
  1931. end
  1932.  
  1933. local creativeInventoryGUI = makeInventory()
  1934.  
  1935. local humRootPart = char:WaitForChild("HumanoidRootPart")
  1936. local head = char:WaitForChild("Head")
  1937. local torso = char:WaitForChild("Torso")
  1938. local lArm = char:WaitForChild("Left Arm")
  1939. local rArm = char:WaitForChild("Right Arm")
  1940. local lLeg = char:WaitForChild("Left Leg")
  1941. local rLeg = char:WaitForChild("Right Leg")
  1942.  
  1943. local humanoid = char:WaitForChild("Humanoid")
  1944. char.Humanoid:ClearAllChildren()
  1945. humanoid.HipHeight = 0.3
  1946. humanoid.AutoRotate = false
  1947.  
  1948. -- Heart bar
  1949. local hpFrame = makeSquare(UDim2.new(0.5, -166, 1, -130), UDim2.new(0, 162, 0, 18),
  1950. Color3.new(0/255, 0/255, 0/255), 1, gui, 1)
  1951.  
  1952. local hearts = makeSquare(UDim2.new(0, 0, 0, 0), UDim2.new(0, 162, 0, 18),
  1953. Color3.new(0/255, 0/255, 0/255), 1, hpFrame, 1)
  1954. hearts.ClipsDescendants = true
  1955.  
  1956. for i = 1, 10 do
  1957. local heartImg = makeImage(UDim2.new(0, (i-1)*16, 0, 0), UDim2.new(0, 18, 0, 18),
  1958. "rbxassetid://1494233443", hearts, 2)
  1959.  
  1960. makeSquare(UDim2.new(0, 4, 0, 4), UDim2.new(0, 2, 0, 2),
  1961. Color3.new(255/255, 200/255, 200/255), 0, heartImg, 2)
  1962.  
  1963. heartImg.ImageColor3 = Color3.new(240/255, 0, 0)
  1964.  
  1965. local emptyHeart = makeImage(UDim2.new(0, (i-1)*16, 0, 0), UDim2.new(0, 18, 0, 18),
  1966. "rbxassetid://1494233443", hpFrame, 1)
  1967. emptyHeart.ImageColor3 = Color3.new(0.3, 0.3, 0.3)
  1968.  
  1969. local outline = makeImage(UDim2.new(0, 0, 0, 0), UDim2.new(0, 18, 0, 18),
  1970. "rbxassetid://1494176679", emptyHeart, 1)
  1971. outline.ImageColor3 = Color3.new(0, 0, 0)
  1972.  
  1973. local oldHP = humanoid.Health/humanoid.MaxHealth --SnapToGrid((humanoid.Health/humanoid.MaxHealth)*162, 8)
  1974. humanoid.Changed:connect(function()
  1975. local hp = humanoid.Health/humanoid.MaxHealth --SnapToGrid((humanoid.Health/humanoid.MaxHealth)*162, 8)
  1976. if SnapToGrid(oldHP*162, 8) < SnapToGrid(hp*162, 8) then
  1977. outline.ImageColor3 = Color3.new(1, 1, 1)
  1978. wait(0.1)
  1979. outline.ImageColor3 = Color3.new(0, 0, 0)
  1980. wait(0.1)
  1981. end
  1982. if oldHP > hp then
  1983. for i = 1, 2 do
  1984. outline.ImageColor3 = Color3.new(1, 1, 1)
  1985. wait(0.1)
  1986. outline.ImageColor3 = Color3.new(0, 0, 0)
  1987. wait(0.1)
  1988. end
  1989. end
  1990. oldHP = hp
  1991. end)
  1992. coroutine.resume(coroutine.create(function()
  1993. local yIncrease = 0
  1994. local originalY = emptyHeart.Position.Y.Offset
  1995.  
  1996. while wait() do
  1997. if humanoid.Health/humanoid.MaxHealth <= 0.27 then
  1998. if yIncrease <= 0 then
  1999. yIncrease = math.random(1, 2)
  2000. else
  2001. yIncrease = yIncrease - 1
  2002. end
  2003.  
  2004. heartImg.Position = UDim2.new(0, heartImg.Position.X.Offset, 0, -yIncrease)
  2005. emptyHeart.Position = UDim2.new(0, emptyHeart.Position.X.Offset, 0, -yIncrease)
  2006. else
  2007. if yIncrease >= 1 then
  2008. yIncrease = yIncrease - 1
  2009.  
  2010. heartImg.Position = UDim2.new(0, heartImg.Position.X.Offset, 0, -yIncrease)
  2011. emptyHeart.Position = UDim2.new(0, emptyHeart.Position.X.Offset, 0, -yIncrease)
  2012. end
  2013. end
  2014. end
  2015. end))
  2016. end
  2017.  
  2018. humanoid.Parent = nil
  2019.  
  2020. if char:FindFirstChild("Animate") then
  2021. char.Animate:Remove()
  2022. end
  2023.  
  2024. head.Size = Vector3.new(1.3, 1.3, 1.3)
  2025. putTexture(head, "rbxassetid://38738031", "rbxassetid://36047330",
  2026. "rbxassetid://36047341", "rbxassetid://36047347",
  2027. "rbxassetid://36047323", "rbxassetid://36047315", "Decal")
  2028. head:WaitForChild("Mesh"):Destroy()
  2029. head:WaitForChild("face"):Destroy()
  2030.  
  2031. torso.Size = Vector3.new(1.3, 1.95, 0.65)
  2032. putTexture(torso, "rbxassetid://38934753", "rbxassetid://38934731",
  2033. "rbxassetid://38934780", "rbxassetid://38934740",
  2034. "rbxassetid://38934762", "rbxassetid://38934762", "Decal")
  2035.  
  2036. lArm.Size = Vector3.new(0.65, 1.95, 0.65)
  2037. putTexture(lArm, "rbxassetid://38934581", "rbxassetid://38934560",
  2038. "rbxassetid://38934613", "rbxassetid://38934568",
  2039. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  2040.  
  2041. rArm.Size = Vector3.new(0.65, 1.95, 0.65)
  2042. putTexture(rArm, "rbxassetid://38934560", "rbxassetid://38934581",
  2043. "rbxassetid://38934613", "rbxassetid://38934568",
  2044. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  2045.  
  2046. lLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  2047. putTexture(lLeg, "rbxassetid://38936226", "rbxassetid://38936209",
  2048. "rbxassetid://38934719", "rbxassetid://38934712",
  2049. "rbxassetid://38936255", "rbxassetid://38936242", "Decal")
  2050.  
  2051. rLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  2052. putTexture(rLeg, "rbxassetid://38936209", "rbxassetid://38936226",
  2053. "rbxassetid://38934719", "rbxassetid://38934712",
  2054. "rbxassetid://38936242", "rbxassetid://38936255", "Decal")
  2055.  
  2056. -- now for the real stuff
  2057. -- |
  2058. -- |
  2059. -- V
  2060. Instance.new("BlockMesh", torso)
  2061. Instance.new("BlockMesh", lArm)
  2062. Instance.new("BlockMesh", rArm)
  2063. Instance.new("BlockMesh", lLeg)
  2064. Instance.new("BlockMesh", rLeg)
  2065.  
  2066. local camera = workspace.Camera
  2067.  
  2068. local camPart = Instance.new("Part", camera)
  2069. camPart.Size = Vector3.new(0, 0, 0)
  2070. camPart.CFrame = camera.CFrame
  2071. camPart.CanCollide = false
  2072. camPart.Anchored = true
  2073. camPart.Transparency = 1
  2074.  
  2075. local cameraHand = Instance.new("Part", camera)
  2076. cameraHand.Size = Vector3.new(0.65, 1.95, 0.65)
  2077. cameraHand.CanCollide = false
  2078. cameraHand.Anchored = true
  2079. cameraHand.Name = "CameraHand"
  2080. putTexture(cameraHand, "rbxassetid://38934560", "rbxassetid://38934581",
  2081. "rbxassetid://38934613", "rbxassetid://38934568",
  2082. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  2083.  
  2084. local cameraHandItem = Instance.new("Part", camera)
  2085. cameraHandItem.Name = "CameraHandItem"
  2086. cameraHandItem.Size = Vector3.new(1.1, 1.1, 1.1)
  2087. cameraHandItem.Anchored = true
  2088. cameraHandItem.CanCollide = false
  2089. cameraHandItem.Transparency = 1
  2090.  
  2091. -- welding doesn't really work.
  2092. --local cameraHandWeld = Instance.new("Motor6D", camPart)
  2093. --cameraHandWeld.Part0 = camPart
  2094. --cameraHandWeld.Part1 = cameraHand
  2095. --cameraHandWeld.C0 = CFrame.new(5, 0, 0)
  2096.  
  2097. local rootJoint = torso:FindFirstChild("RootJoint") or Instance.new("Motor6D", torso)
  2098. rootJoint.Name = "RootJoint"
  2099. rootJoint.Part0 = humRootPart
  2100. rootJoint.Part1 = torso
  2101. rootJoint.C1 = CFrame.new(0, 0.05, 0)
  2102.  
  2103. local neck = torso:FindFirstChild("Neck") or Instance.new("Motor6D", torso)
  2104. neck.Name = "Neck"
  2105. neck.Part0 = head
  2106. neck.Part1 = torso
  2107.  
  2108. local lS = torso:FindFirstChild("Left Shoulder") or Instance.new("Motor6D", torso)
  2109. lS.Name = "Left Shoulder"
  2110. lS.Part0 = lArm
  2111. lS.Part1 = torso
  2112. lS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2113. lS.C1 = CFrame.new(0.65, 0.975, 0)
  2114.  
  2115. local rS = torso:FindFirstChild("Right Shoulder") or Instance.new("Motor6D", torso)
  2116. rS.Name = "Right Shoulder"
  2117. rS.Part0 = rArm
  2118. rS.Part1 = torso
  2119. rS.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2120. rS.C1 = CFrame.new(-0.65, 0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  2121.  
  2122. local lH = torso:FindFirstChild("Left Hip") or Instance.new("Motor6D", torso)
  2123. lH.Name = "Left Hip"
  2124. lH.Part0 = lLeg
  2125. lH.Part1 = torso
  2126. lH.C0 = CFrame.new(0, 0.975, 0)
  2127. lH.C1 = CFrame.new(0.325, -0.975, 0) * CFrame.Angles(0, 0, 0)
  2128.  
  2129. local rH = torso:FindFirstChild("Right Hip") or Instance.new("Motor6D", torso)
  2130. rH.Name = "Right Hip"
  2131. rH.Part0 = rLeg
  2132. rH.Part1 = torso
  2133. rH.C0 = CFrame.new(0, 0.975, 0)
  2134. rH.C1 = CFrame.new(-0.325, -0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  2135.  
  2136. for _,p in pairs(char:GetChildren()) do
  2137. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  2138. local hit = Instance.new("Part", char)
  2139. hit.Name = "DamagePart"
  2140. hit.BrickColor = BrickColor.new("Bright red")
  2141. hit.Material = "SmoothPlastic"
  2142. hit.Transparency = 1
  2143. hit.Size = Vector3.new(p.Size.X + 0.05, p.Size.Y + 0.05, p.Size.Z + 0.05)
  2144. hit.CanCollide = false
  2145. weldTo(hit, p)
  2146. end
  2147. end
  2148.  
  2149. wait(0.25)
  2150.  
  2151. -- local billNameTag = Instance.new("BillboardGui", char)
  2152. -- billNameTag.Size = UDim2.new(1, 0, 1, 0)
  2153. -- billNameTag.Adornee = head
  2154. -- billNameTag.PlayerToHideFrom = player
  2155. --
  2156. -- local textLabel = Instance.new("TextLabel", billNameTag)
  2157. -- textLabel.Font = "Arcade"
  2158. -- --textLabel.Size = UDim2.new(1, 0, 1, 0)
  2159. -- textLabel.TextScaled = true
  2160. -- --textLabel.TextSize = 100
  2161. -- textLabel.Text = targetName
  2162. -- textLabel.Size = UDim2.new(textLabel.TextBounds.X/100, 0, 0.75, 0)
  2163. -- textLabel.BorderSizePixel = 0
  2164. -- textLabel.BackgroundColor3 = Color3.new(0, 0, 0)
  2165. -- textLabel.TextColor3 = Color3.new(1, 1, 1)
  2166. -- textLabel.BackgroundTransparency = 0.5
  2167. --
  2168. -- if textLabel.Text == "Depr1" then
  2169. -- textLabel.TextColor3 = Color3.new(1, 0.75, 0)
  2170. -- end
  2171. --
  2172. -- billNameTag.SizeOffset = Vector2.new(-textLabel.TextBounds.X/200 + 0.5, 0)
  2173. -- billNameTag.StudsOffset = Vector3.new(0, 1.5, 0)
  2174.  
  2175.  
  2176. humanoid.Parent = char
  2177.  
  2178. local ticks = 0
  2179. local times = 0
  2180.  
  2181. local walkAnim = 0
  2182. local increaseWalkAnim = 1
  2183.  
  2184. local idleAnimRotX = 0
  2185. local idleAnimRotZ = 0
  2186. local sneaking = 0
  2187.  
  2188. --local RS = game:GetService("RunService").RenderStepped
  2189. local Mouse = player:GetMouse()
  2190.  
  2191. local oldHP = humanoid.Health
  2192. local damageTime = 0
  2193.  
  2194. local punchRotX = 0
  2195. local punchRotY = 0
  2196. local punchRotZ = 0
  2197. local punchRotXcam = 0
  2198. local punchRotYcam = 0
  2199. local punchRotZcam = 0
  2200. local punchSpeed = 0
  2201. local punching = 0
  2202. local selectedBlock = 8
  2203. local punchEnded = 1
  2204. local itemOnHand = nil
  2205.  
  2206. local selectBox = Instance.new("SelectionBox", camera)
  2207. selectBox.Transparency = 0.5
  2208. selectBox.Color3 = Color3.new(0, 0, 0)
  2209. selectBox.LineThickness = 0
  2210.  
  2211. local handItem = Instance.new("Part", char)
  2212. handItem.Name = "HandItem"
  2213. handItem.Size = Vector3.new(0.52, 0.52, 0.52)
  2214. handItem.Transparency = 1
  2215. handItem.CanCollide = false
  2216.  
  2217. local handItemWeld = Instance.new("Weld", char)
  2218. handItemWeld.Part0 = handItem
  2219. handItemWeld.Part1 = lArm
  2220. handItemWeld.C1 = CFrame.new(0, -0.9, -0.6) * CFrame.Angles(math.rad(-10), math.rad(45), 0)
  2221.  
  2222. local sound = Instance.new("Sound", char)
  2223. sound.Name = "Hurt"
  2224. sound.Volume = 10
  2225. sound.SoundId = "rbxassetid://535690488"
  2226.  
  2227. local facesToResize = {"Front", "Back", "Left", "Right", "Bottom", "Top"}
  2228.  
  2229. local camCurrentZoom = (camera.CFrame.p - head.Position).magnitude
  2230. Mouse.Button1Down:connect(function()
  2231. if punchEnded == 1 then punching = 1 end
  2232. if Mouse.Target then
  2233. if getDistance(head.CFrame.p, Mouse.Hit.p) <= 10.4 then
  2234. local humanoid = Mouse.Target.Parent:FindFirstChild("Humanoid")
  2235. if humanoid then
  2236. humanoid.Health = humanoid.Health - 10
  2237. local parts = Mouse.Target.Parent:GetChildren()
  2238. for _,p in pairs(parts) do
  2239. if p.ClassName == "Part" then
  2240. p.Velocity = Vector3.new(p.Velocity.X + (head.CFrame.lookVector.X * 18), p.Velocity.Y + (head.CFrame.lookVector.Y * 18) + 8, p.Velocity.Z + (head.CFrame.lookVector.Z * 18))
  2241. end
  2242. end
  2243. return
  2244. end
  2245. local x = Mouse.Target.CFrame.p.X
  2246. local y = Mouse.Target.CFrame.p.Y
  2247. local z = Mouse.Target.CFrame.p.Z
  2248. if Mouse.TargetSurface.Name == "Right" then x = x + 2.6 end
  2249. if Mouse.TargetSurface.Name == "Left" then x = x - 2.6 end
  2250. if Mouse.TargetSurface.Name == "Top" then y = y + 2.6 end
  2251. if Mouse.TargetSurface.Name == "Bottom" then y = y - 2.6 end
  2252. if Mouse.TargetSurface.Name == "Back" then z = z + 2.6 end
  2253. if Mouse.TargetSurface.Name == "Front" then z = z - 2.6 end
  2254. if Mouse.Target.Size.X > 2.6 or Mouse.Target.Size.Y > 2.6 or Mouse.Target.Size.Z > 2.6 then
  2255. x = Mouse.Hit.p.X
  2256. y = Mouse.Hit.p.Y
  2257. z = Mouse.Hit.p.Z
  2258. end
  2259. -- local x = round(math.abs(mouseX)/2.6)*2.6
  2260. -- local y = round(math.abs(mouseY)/2.6)*2.6
  2261. -- local z = round(math.abs(mouseZ)/2.6)*2.6
  2262. -- if Mouse.Hit.p.X < 0 then x = x * -1 end
  2263. -- if Mouse.Hit.p.Y < 0 then y = y * -1 end
  2264. -- if Mouse.Hit.p.Z < 0 then z = z * -1 end
  2265. local blk = placeBlock(toolBar[selectedBlock + 1], CFrame.new(SnapToGrid(x, 2.6), SnapToGrid(y, 2.6), SnapToGrid(z, 2.6)), Mouse)
  2266. if blk then
  2267. for _,f in pairs(facesToResize) do
  2268. blk:WaitForChild(f).StudsPerTileU = 2.6
  2269. blk:WaitForChild(f).StudsPerTileV = 2.6
  2270. end
  2271. end
  2272. end
  2273. end
  2274. end)
  2275.  
  2276. local changedItem = false
  2277. local hasItemOnHand = 0
  2278. local hi = 0
  2279. -- selection thingy
  2280. local selectLabel = Instance.new("TextLabel", gui)
  2281. selectLabel.Size = UDim2.new(0, 32, 0, 32)
  2282. selectLabel.Position = UDim2.new(0.5, -160 + (selectedBlock*40), 1, -105)
  2283. selectLabel.BackgroundTransparency = 1
  2284. selectLabel.BackgroundColor3 = Color3.new(1, 1, 1)
  2285. selectLabel.BorderSizePixel = 0
  2286. selectLabel.Text = ""
  2287. selectLabel.ZIndex = 3
  2288.  
  2289. makeSquare(UDim2.new(0, -2, 0, 0), UDim2.new(0, 2, 0, 32),
  2290. Color3.new(88/255, 102/255, 85/255), 0, selectLabel, 3)
  2291. makeSquare(UDim2.new(0, -2, 0, -2), UDim2.new(0, 32, 0, 2),
  2292. Color3.new(88/255, 102/255, 85/255), 0, selectLabel, 3)
  2293. makeSquare(UDim2.new(0, -2, 0, 32), UDim2.new(0, 36, 0, 2),
  2294. Color3.new(212/255, 231/255, 207/255), 0, selectLabel, 3)
  2295. makeSquare(UDim2.new(0, 32, 0, 0), UDim2.new(0, 2, 0, 32),
  2296. Color3.new(212/255, 231/255, 207/255), 0, selectLabel, 3)
  2297. makeSquare(UDim2.new(0, 34, 0, -4), UDim2.new(0, 2, 0, 40),
  2298. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2299. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 2, 0, 40),
  2300. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2301. makeSquare(UDim2.new(0, -4, 0, -4), UDim2.new(0, 40, 0, 2),
  2302. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2303. makeSquare(UDim2.new(0, 32, 0, -2), UDim2.new(0, 2, 0, 2),
  2304. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2305. makeSquare(UDim2.new(0, -4, 0, 34), UDim2.new(0, 40, 0, 2),
  2306. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2307. makeSquare(UDim2.new(0, -6, 0, -6), UDim2.new(0, 2, 0, 42),
  2308. Color3.new(212/255, 231/255, 207/255), 0, selectLabel, 3)
  2309. makeSquare(UDim2.new(0, -6, 0, -6), UDim2.new(0, 42, 0, 2),
  2310. Color3.new(212/255, 231/255, 207/255), 0, selectLabel, 3)
  2311. makeSquare(UDim2.new(0, 36, 0, -4), UDim2.new(0, 2, 0, 40),
  2312. Color3.new(88/255, 102/255, 85/255), 0, selectLabel, 3)
  2313. makeSquare(UDim2.new(0, 36, 0, -6), UDim2.new(0, 2, 0, 2),
  2314. Color3.new(163/255, 180/255, 159/255), 0, selectLabel, 3)
  2315. makeSquare(UDim2.new(0, 38, 0, -6), UDim2.new(0, 2, 0, 44),
  2316. Color3.new(0/255, 0/255, 0/255), 0.3, selectLabel, 3)
  2317. makeSquare(UDim2.new(0, -8, 0, -6), UDim2.new(0, 2, 0, 44),
  2318. Color3.new(0/255, 0/255, 0/255), 0.3, selectLabel, 3)
  2319. makeSquare(UDim2.new(0, -8, 0, -8), UDim2.new(0, 48, 0, 2),
  2320. Color3.new(0/255, 0/255, 0/255), 0, selectLabel, 3)
  2321. --
  2322. local oldItemOnHand = itemOnHand
  2323. function updateItemOnHand()
  2324. for _,d in pairs(handItem:GetChildren()) do
  2325. d:Destroy()
  2326. end
  2327. for _,d in pairs(cameraHandItem:GetChildren()) do
  2328. d:Destroy()
  2329. end
  2330. if itemOnHand ~= nil then
  2331. putTexture(handItem, itemOnHand.frontTex, itemOnHand.backTex,
  2332. itemOnHand.topTex, itemOnHand.bottomTex,
  2333. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  2334.  
  2335. putTexture(cameraHandItem, itemOnHand.frontTex, itemOnHand.backTex,
  2336. itemOnHand.topTex, itemOnHand.bottomTex,
  2337. itemOnHand.leftTex, itemOnHand.rightTex, "Texture")
  2338.  
  2339. for _,f in pairs(facesToResize) do
  2340. handItem:WaitForChild(f).StudsPerTileU = 0.52
  2341. handItem:WaitForChild(f).StudsPerTileV = 0.52
  2342. end
  2343.  
  2344. for _,f in pairs(facesToResize) do
  2345. cameraHandItem:WaitForChild(f).StudsPerTileU = 1.1
  2346. cameraHandItem:WaitForChild(f).StudsPerTileV = 1.1
  2347. end
  2348.  
  2349. cameraHand.Transparency = 1
  2350. for _,f in pairs(facesToResize) do
  2351. cameraHand:WaitForChild(f).Transparency = 1
  2352. cameraHand:WaitForChild(f).Transparency = 1
  2353. end
  2354. else
  2355. cameraHand.Transparency = 0
  2356. for _,f in pairs(facesToResize) do
  2357. cameraHand:WaitForChild(f).Transparency = 0
  2358. cameraHand:WaitForChild(f).Transparency = 0
  2359. end
  2360. end
  2361. if oldItemOnHand ~= itemOnHand then
  2362. changedItem = true
  2363. end
  2364. end
  2365.  
  2366. local pressedWTimes = 0
  2367. local sprintingNum = 0
  2368. local sprinting = false
  2369. Mouse.KeyDown:connect(function(key)
  2370. if sprinting == false then sprintingNum = 0 else sprintingNum = 1 end
  2371. if (key == "w" and sprinting == false and sneaking == 0) then
  2372. if pressedWTimes >= 1 or key == Enum.KeyCode.LeftControl then
  2373. sprinting = true
  2374. humanoid.WalkSpeed = humanoid.WalkSpeed * 1.5
  2375. pressedWTimes = 0
  2376. coroutine.resume(coroutine.create(function()
  2377. for i = 1, 24 do
  2378. camera.FieldOfView = camera.FieldOfView + ((24-i)/10)
  2379. RS:wait()
  2380. end
  2381. end))
  2382. end
  2383. pressedWTimes = pressedWTimes + 1
  2384. coroutine.resume(coroutine.create(function()
  2385. for i = 1, 9 do
  2386. if sprinting == true then break end
  2387. wait()
  2388. end
  2389. pressedWTimes = 0
  2390. end))
  2391. end
  2392. if key == "q" and sprinting == false then
  2393. sneaking = 1
  2394. humanoid.WalkSpeed = humanoid.WalkSpeed / 2
  2395. humanoid.HipHeight = humanoid.HipHeight - 0.35
  2396. rootJoint.C1 = CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  2397. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  2398. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  2399. --print("Sneaking...")
  2400. end
  2401. if key == "e" then
  2402. if creativeInventoryGUI.Visible == true then
  2403. creativeInventoryGUI.Visible = false
  2404. elseif creativeInventoryGUI.Visible == false then
  2405. creativeInventoryGUI.Visible = true
  2406. end
  2407. end
  2408. if key == "1" or key == "2" or key == "3" or
  2409. key == "4" or key == "5" or key == "6" or
  2410. key == "7" or key == "8" or key == "9" then
  2411. selectedBlock = tonumber(key) - 1
  2412. oldItemOnHand = itemOnHand
  2413. itemOnHand = toolBar[tonumber(key)]
  2414. updateItemOnHand()
  2415. if hasItemOnHand == 0 and itemOnHand then hi = 1 end
  2416. if hasItemOnHand == 1 and itemOnHand == nil then hi = 1 end
  2417. end
  2418. --if (key == "0" or key == "1" or key == "2"
  2419. -- or key == "3" or key == "4" or key == "5"
  2420. -- or key == "6" or key == "7") and hasItemOnHand == 0 then hi = 1 end
  2421. selectLabel.Position = UDim2.new(0.5, -160 + ((selectedBlock)*40), 1, -105)
  2422. end)
  2423.  
  2424. local interrump = false
  2425. game:GetService('RunService'):BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, function()
  2426. if humanoid.Health < oldHP then
  2427. interrump = true
  2428. RS:wait()
  2429. interrump = false
  2430. for i = 1, 15 do
  2431. if interrump == true then interrump = false break end
  2432. camera.CFrame = camera.CFrame * CFrame.Angles(0, 0, -math.rad(15-i))
  2433. RS:wait()
  2434. end
  2435. end
  2436. end)
  2437.  
  2438. local changedPerspective = 0
  2439. Mouse.KeyUp:connect(function(key)
  2440. if sprinting == false then sprintingNum = 0 else sprintingNum = 1 end
  2441. if (key == "w" and sprinting == true and sneaking == 0) then
  2442. sprinting = false
  2443. humanoid.WalkSpeed = humanoid.WalkSpeed / 1.5
  2444. coroutine.resume(coroutine.create(function()
  2445. for i = 1, 24 do
  2446. camera.FieldOfView = camera.FieldOfView - ((24-i)/10)
  2447. RS:wait()
  2448. end
  2449. end))
  2450. end
  2451. if key == "q" and sprinting == false then
  2452. sneaking = 0
  2453. humanoid.WalkSpeed = humanoid.WalkSpeed * 2
  2454. humanoid.HipHeight = humanoid.HipHeight + 0.35
  2455. rootJoint.C1 = CFrame.new(0, 0.05, 0) * CFrame.Angles(0, 0, 0)
  2456. lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2457. rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2458. --print("Stopped sneaking...")
  2459. end
  2460. if key == "r" then
  2461. if changedPerspective == 0 then
  2462. changedPerspective = 1
  2463. camera.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(180), 0)
  2464. elseif changedPerspective == 1 then
  2465. changedPerspective = 0
  2466. camera.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(-180), 0)
  2467. end
  2468. end
  2469. end)
  2470.  
  2471. Mouse.TargetFilter = camera
  2472.  
  2473. local dead = false
  2474. local humOffset = CFrame.new(0, 0, 0)
  2475. local camHandY = 0
  2476. local camHandZ = 0
  2477. local cameraHandCFrame = CFrame.new(1.15, -1.35, -2) * CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(55), math.rad(20))
  2478. local bodyRot = CFrame.new(0, 0, 0)
  2479. local lastCamRot = camPart.Orientation
  2480. while RS:wait() do
  2481. hearts.Size = UDim2.new(0, SnapToGrid((humanoid.Health/humanoid.MaxHealth)*162, 8) + 2, 0, 18)
  2482. camCurrentZoom = ((CFrame.new(0, -1*sneaking, 0) * camera.CFrame).p - head.Position).magnitude
  2483. if itemOnHand ~= nil then
  2484. hasItemOnHand = 1
  2485. handItem.Transparency = itemOnHand.transparency
  2486. else
  2487. hasItemOnHand = 0
  2488. handItem.Transparency = 1
  2489. end
  2490. if humanoid.Health <= 0 and dead == false then
  2491. dead = true
  2492. local corpseCF = humRootPart.CFrame + Vector3.new(0, -2.925, 0)
  2493. local corpse = Instance.new("Part", workspace)
  2494. corpse.Name = "Dead Corpse"
  2495. corpse.Size = Vector3.new(3, 1, 3)
  2496. corpse.CFrame = corpseCF
  2497. corpse.Transparency = 1
  2498. corpse.CustomPhysicalProperties = PhysicalProperties.new(1, 1, 0, 1, 1)
  2499.  
  2500. local dHead = Instance.new("Part", corpse)
  2501. dHead.CanCollide = false
  2502. dHead.Material = "Fabric"
  2503.  
  2504. local dTorso = Instance.new("Part", corpse)
  2505. dTorso.CanCollide = false
  2506. dTorso.Material = "Fabric"
  2507.  
  2508. local dLArm = Instance.new("Part", corpse)
  2509. dLArm.CanCollide = false
  2510. dLArm.Material = "Fabric"
  2511.  
  2512. local dRArm = Instance.new("Part", corpse)
  2513. dRArm.CanCollide = false
  2514. dRArm.Material = "Fabric"
  2515.  
  2516. local dLLeg = Instance.new("Part", corpse)
  2517. dLLeg.CanCollide = false
  2518. dLLeg.Material = "Fabric"
  2519.  
  2520. local dRLeg = Instance.new("Part", corpse)
  2521. dRLeg.CanCollide = false
  2522. dRLeg.Material = "Fabric"
  2523.  
  2524. dHead.Size = Vector3.new(1.3, 1.3, 1.3)
  2525. putTexture(dHead, "rbxassetid://38738031", "rbxassetid://36047330",
  2526. "rbxassetid://36047341", "rbxassetid://36047347",
  2527. "rbxassetid://36047323", "rbxassetid://36047315", "Decal")
  2528.  
  2529. dTorso.Size = Vector3.new(1.3, 1.95, 0.65)
  2530. putTexture(dTorso, "rbxassetid://38934753", "rbxassetid://38934731",
  2531. "rbxassetid://38934780", "rbxassetid://38934740",
  2532. "rbxassetid://38934762", "rbxassetid://38934762", "Decal")
  2533.  
  2534. dLArm.Size = Vector3.new(0.65, 1.95, 0.65)
  2535. putTexture(dLArm, "rbxassetid://38934581", "rbxassetid://38934560",
  2536. "rbxassetid://38934613", "rbxassetid://38934568",
  2537. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  2538.  
  2539. dRArm.Size = Vector3.new(0.65, 1.95, 0.65)
  2540. putTexture(dRArm, "rbxassetid://38934560", "rbxassetid://38934581",
  2541. "rbxassetid://38934613", "rbxassetid://38934568",
  2542. "rbxassetid://38934601", "rbxassetid://38934591", "Decal")
  2543.  
  2544. dLLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  2545. putTexture(dLLeg, "rbxassetid://38936226", "rbxassetid://38936209",
  2546. "rbxassetid://38934719", "rbxassetid://38934712",
  2547. "rbxassetid://38936255", "rbxassetid://38936242", "Decal")
  2548.  
  2549. dRLeg.Size = Vector3.new(0.65, 1.95, 0.65)
  2550. putTexture(dRLeg, "rbxassetid://38936209", "rbxassetid://38936226",
  2551. "rbxassetid://38934719", "rbxassetid://38934712",
  2552. "rbxassetid://38936242", "rbxassetid://38936255", "Decal")
  2553.  
  2554. local weldCorpse = weldTo(dTorso, corpse)
  2555. weldCorpse.C0 = CFrame.new(0, -1.95 - 0.4, 0)
  2556.  
  2557. -- lazy naming...
  2558.  
  2559. local weld1 = weldTo(dTorso, dHead)
  2560. weld1.C0 = CFrame.new(0, 1.625, 0)
  2561.  
  2562. local weld2 = weldTo(dTorso, dLArm)
  2563. weld2.C0 = CFrame.new(0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2564. weld2.C1 = CFrame.new(-0.65, 0.975, 0)
  2565.  
  2566. local weld3 = weldTo(dTorso, dRArm)
  2567. weld3.C0 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2568. weld3.C1 = CFrame.new(-0.65, 0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  2569.  
  2570. local weld4 = weldTo(dTorso, dLLeg)
  2571. weld4.C0 = CFrame.new(0, -0.975, 0)
  2572. weld4.C1 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, 0, 0)
  2573.  
  2574. local weld5 = weldTo(dTorso, dRLeg)
  2575. weld5.C0 = CFrame.new(0, -0.975, 0)
  2576. weld5.C1 = CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(0, -math.rad(180), 0)
  2577.  
  2578. for _,p in pairs(corpse:GetChildren()) do
  2579. if p.ClassName == "Part" then
  2580. local hit = Instance.new("Part", p)
  2581. hit.Name = "DamagePart"
  2582. hit.BrickColor = BrickColor.new("Bright red")
  2583. hit.Material = "SmoothPlastic"
  2584. hit.Transparency = 0.5
  2585. hit.Size = Vector3.new(p.Size.X + 0.05, p.Size.Y + 0.05, p.Size.Z + 0.05)
  2586. hit.CanCollide = false
  2587. weldTo(hit, p)
  2588. end
  2589. end
  2590.  
  2591. head.Parent = nil
  2592. torso.Parent = nil
  2593. lArm.Parent = nil
  2594. rArm.Parent = nil
  2595. lLeg.Parent = nil
  2596. rLeg.Parent = nil
  2597.  
  2598. weldTo(dTorso, humRootPart)
  2599.  
  2600. coroutine.resume(coroutine.create(function()
  2601. for i = 1, 55 do
  2602. corpse.CFrame = corpseCF --*
  2603. --CFrame.Angles(math.rad(-corpse.Orientation.X), 0, math.rad(-corpse.Orientation.Z))
  2604.  
  2605. weldCorpse.C1 = weldCorpse.C1:lerp(CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, math.rad(90)), 0.075)
  2606. RS:wait()
  2607. end
  2608. for _,p in pairs(corpse:GetChildren()) do
  2609. p:Destroy()
  2610. end
  2611.  
  2612. corpse.Anchored = true
  2613.  
  2614. local smoke = Instance.new("ParticleEmitter", corpse)
  2615. smoke.Size = NumberSequence.new({
  2616. NumberSequenceKeypoint.new(0, 0.6),
  2617. NumberSequenceKeypoint.new(1, 0.6)
  2618. })
  2619. smoke.Texture = "rbxassetid://1494734425"
  2620. smoke.Rate = 100
  2621. smoke.Lifetime = NumberRange.new(0.6, 1.2)
  2622. smoke.Speed = NumberRange.new(2, 5)
  2623. smoke.SpreadAngle = Vector2.new(-30, 30)
  2624.  
  2625. wait(0.07)
  2626.  
  2627. smoke.Enabled = false
  2628.  
  2629. wait(2)
  2630.  
  2631. corpse:Destroy()
  2632. end))
  2633. print("You died!")
  2634. end
  2635. if humanoid.Health < oldHP then
  2636. damageTime = 60
  2637. sound:Play()
  2638. end
  2639. oldHP = humanoid.Health
  2640. if damageTime > 0 and humanoid.Health > 0 then
  2641. for _,p in pairs(char:GetChildren()) do
  2642. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  2643. if p.Name == "DamagePart" then
  2644. p.Transparency = 0.5
  2645. end
  2646. end
  2647. end
  2648. damageTime = damageTime - 2
  2649. if damageTime <= 0 then
  2650. for _,p in pairs(char:GetChildren()) do
  2651. if p.Name ~= "HumanoidRootPart" and p.ClassName == "Part" then
  2652. if p.Name == "DamagePart" then
  2653. p.Transparency = 1
  2654. end
  2655. end
  2656. end
  2657. end
  2658. end
  2659. camPart.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(changedPerspective*180), 0)
  2660.  
  2661. if getMagnitudeXZ(torso.Velocity) > 1 then
  2662. if walkAnim >= 1 then
  2663. increaseWalkAnim = -1
  2664. elseif walkAnim <= -1 then
  2665. increaseWalkAnim = 1
  2666. end
  2667. walkAnim = walkAnim + (increaseWalkAnim/(10+(sneaking*20))) * ((5 + getMagnitudeXZ(torso.Velocity))/20)
  2668. else
  2669. walkAnim = 0
  2670. end
  2671.  
  2672. --lH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(-math.rad(sneaking*45), 0, 0)
  2673. --rH.C0 = CFrame.new(0, 0.975, 0) * CFrame.Angles(math.rad(sneaking*45), 0, 0)
  2674. lH.C0 = lH.C0:lerp(CFrame.new(0, 0.975, 0) * CFrame.Angles(math.max(math.rad(-60), math.min(math.rad(60), -math.rad(sneaking*45) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)))), 0, 0), 0.15)
  2675. rH.C0 = rH.C0:lerp(CFrame.new(0, 0.975, 0) * CFrame.Angles(math.max(math.rad(-60), math.min(math.rad(60), math.rad(sneaking*45) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)))), 0, 0), 0.15)
  2676. --
  2677. --rootJoint.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
  2678. --print(math.abs(head.Orientation.Y) - math.abs(humRootPart.Orientation.Y))
  2679. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) > 45 then
  2680. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(-45 + head.Orientation.Y), 0)
  2681. --print("-45")
  2682. --end
  2683. --if (head.Orientation.Y * 2) - (head.Orientation.Y + torso.Orientation.Y) < -45 then
  2684. --humRootPart.CFrame = humRootPart.CFrame * CFrame.Angles(0, math.rad(45 + head.Orientation.Y), 0)
  2685. --print("45")
  2686. --end
  2687.  
  2688. if changedItem then
  2689. changedItem = false
  2690. coroutine.resume(coroutine.create(function()
  2691. for i = 1, 8 do
  2692. camHandY = camHandY - 0.2
  2693. RS:wait()
  2694. end
  2695. for i = 1, 8 do
  2696. camHandY = camHandY + 0.2
  2697. RS:wait()
  2698. end
  2699. end))
  2700. end
  2701.  
  2702. --move these arms
  2703. rootJoint.C1 = rootJoint.C1:lerp(CFrame.new(0, 0.325, 0) * CFrame.Angles(math.rad(sneaking*45), math.rad(punchRotY), 0), 0.2)
  2704.  
  2705. lS.C0 = lS.C0:lerp(CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(math.max(math.rad(-60), math.min(math.rad(60), idleAnimRotX/20 + math.rad(-hasItemOnHand*10) + math.rad(punchRotX) + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)))), 0, math.rad(punchRotZ) + idleAnimRotZ/20), 0.025+(math.min(1, getMagnitudeXZ(torso.Velocity))/12)*2 + divide(punchSpeed, 6) + hi)
  2706. rS.C0 = rS.C0:lerp(CFrame.new(-0.325, 0.975, 0) * CFrame.Angles(math.max(math.rad(-60), math.min(math.rad(60), idleAnimRotX/20 + math.rad(damageTime*1.5) + math.rad(walkAnim*getMagnitudeXZ(torso.Velocity)*5/(1+sneaking)))), 0, idleAnimRotZ/20), 0.025+(math.min(1, getMagnitudeXZ(torso.Velocity))/12)*2)
  2707.  
  2708. if Mouse.Target and getDistance(head.CFrame.p, Mouse.Hit.p) <= 10.4 then
  2709. if Mouse.Target.Parent:FindFirstChild("Humanoid") == nil and Mouse.Target.Parent ~= camera then
  2710. selectBox.Adornee = Mouse.Target
  2711. else
  2712. selectBox.Adornee = nil
  2713. end
  2714. else
  2715. selectBox.Adornee = nil
  2716. end
  2717.  
  2718. --local neckYRot = math.rad(camPart.Orientation.Y - torso.Orientation.Y)
  2719.  
  2720. --neck.C1 = CFrame.new(0, 0.975, 0) * CFrame.fromEulerAnglesXYZ(math.rad(sneaking*45), neckYRot, 0)
  2721. --neck.C0 = CFrame.new(0, -0.65, 0) * CFrame.Angles(-math.rad(camPart.Orientation.X - torso.Orientation.X - (sneaking*45)), 0, 0)
  2722.  
  2723. --print(AngleDifference(camPart.Orientation, torso.Orientation).Y)
  2724.  
  2725. local negate = 1
  2726. if torso.Velocity.Y < 0 then
  2727. negate = -1
  2728. end
  2729.  
  2730. --local vel = math.log(math.abs(torso.Velocity.Y))*negate
  2731. --if vel == math.huge or vel == -math.huge then vel = 0.1 end
  2732. --local vel = torso.Velocity.Y^0.6
  2733.  
  2734. local BobbingY = walkAnim*2
  2735. if BobbingY >= 1 then BobbingY = 1 BobbingY = -BobbingY end
  2736.  
  2737. local rotationSpeed = AngleDifference(camPart.Orientation, lastCamRot)
  2738.  
  2739. local BobbingX = -0.5 + walkAnim
  2740.  
  2741. --cameraHandCFrame = cameraHandCFrame:lerp(CFrame.new(1.15*1.3 + (walkAnim/2 - (walkAnim/4)), -1.35*1.3 + camHandY + (-BobbingY/8) + 0, -0.45 + -camHandZ + ((camera.FieldOfView/45)-1.6)*1.3) * CFrame.Angles(math.rad(punchRotXcam), math.rad(punchRotYcam), math.rad(punchRotZcam)) * CFrame.new(0, 0, -1.75) * CFrame.fromEulerAnglesXYZ(math.rad(85), math.rad(55), math.rad(22.5)), 0.25)
  2742. cameraHandCFrame = cameraHandCFrame:lerp(CFrame.Angles(math.rad(rotationSpeed.X/1.5), math.rad(rotationSpeed.Y/1.5), math.rad(rotationSpeed.Z/1.5)) * CFrame.new(1.15*1.3 + (BobbingX/3.5), -1.35*1.3 + camHandY + ((0.4-BobbingY)/7) + 0, -0.45 + -camHandZ + ((camera.FieldOfView/45)-1.6)*1.3) * CFrame.Angles(math.rad(punchRotXcam), math.rad(punchRotYcam), math.rad(punchRotZcam)) * CFrame.new(0, 0, -1.75) * CFrame.fromEulerAnglesXYZ(math.rad(85), math.rad(55), math.rad(22.5)), 0.25)
  2743.  
  2744. humOffset = humOffset:lerp(CFrame.new(walkAnim/4 - (walkAnim/8), BobbingY/13, 0), 0.25)
  2745. humanoid.CameraOffset = Vector3.new(humOffset.X, humOffset.Y, 0)
  2746.  
  2747. cameraHand.CFrame = camPart.CFrame * cameraHandCFrame
  2748.  
  2749. cameraHandItem.CFrame = cameraHand.CFrame * CFrame.new(0, -0.5, 0) * CFrame.Angles(math.rad(-210), math.rad(-40), math.rad(-100)) * CFrame.new(0, -0.35, 0)
  2750.  
  2751. if camCurrentZoom >= 1.5 then
  2752. cameraHand.Transparency = 1
  2753. for _,t in pairs(cameraHand:GetChildren()) do
  2754. if t.Transparency == 0 then
  2755. t.Transparency = 1
  2756. end
  2757. end
  2758. for _,t in pairs(cameraHandItem:GetChildren()) do
  2759. if t.Transparency == 0 then
  2760. t.Transparency = 1
  2761. end
  2762. end
  2763. else
  2764. changedPerspective = 0
  2765. cameraHand.Transparency = hasItemOnHand
  2766. for _,t in pairs(cameraHand:GetChildren()) do
  2767. if t.Transparency == 1 then
  2768. t.Transparency = hasItemOnHand
  2769. end
  2770. end
  2771. for _,t in pairs(cameraHandItem:GetChildren()) do
  2772. if t.Transparency == 1 then
  2773. t.Transparency = 0
  2774. end
  2775. end
  2776. end
  2777.  
  2778. if updateHand == true then
  2779. updateHand = false
  2780. updateItemOnHand()
  2781. end
  2782.  
  2783. if punching == 1 and punchEnded == 1 then
  2784. punching = 0
  2785. --print("steve uses punch!!")
  2786. local coPunchCam = coroutine.wrap(function()
  2787. local mult = 2.25
  2788. punchRotXcam = 40/2*mult
  2789. punchRotYcam = 25/2*mult
  2790. camHandZ = 2.5
  2791. wait(0.075/4)
  2792. punchRotXcam = 50/2*mult
  2793. punchRotYcam = 25*mult
  2794. punchRotZcam = -10*mult
  2795. camHandZ = 1
  2796. wait(0.075/4)
  2797. punchRotYcam = 50/1.5*mult
  2798. punchRotXcam = -10*mult
  2799. --wait(0.075/2)
  2800. --punchRotYcam = 50
  2801. --punchRotXcam = -10
  2802. wait(0.02)
  2803. punchRotXcam = -20*mult
  2804. wait(0.055)
  2805. camHandZ = 0
  2806. punchRotXcam = 0
  2807. punchRotYcam = 0
  2808. punchRotZcam = 0
  2809. end)
  2810. local coPunch = coroutine.wrap(function()
  2811. punchEnded = 0
  2812. punchSpeed = 1
  2813. punchRotX = -60
  2814. punchRotY = -8
  2815. punchRotZ = -35
  2816.  
  2817. wait(0.075/1.3)
  2818. punchSpeed = 1
  2819. punchRotX = -75
  2820. punchRotY = 8
  2821. punchRotZ = 40
  2822. wait(0.075/1.3)
  2823. punchSpeed = 1
  2824. punchRotX = -20
  2825. punchRotZ = 40
  2826. wait(0.075/1.3)
  2827. punchSpeed = 3.5
  2828. punchRotX = 0
  2829. punchRotY = 0
  2830. punchRotZ = 0
  2831.  
  2832. punchRotXcam = 0
  2833. punchRotYcam = 0
  2834. punchRotZcam = 0
  2835.  
  2836. punchEnded = 1
  2837. wait(0.06/1.3)
  2838. punchSpeed = 0
  2839. end)
  2840. coPunch()
  2841. coPunchCam()
  2842. end
  2843. if ticks > 20 then
  2844. ticks = 0
  2845. if times == 0 then
  2846. times = times + 1
  2847. idleAnimRotX = -1
  2848. idleAnimRotZ = 0
  2849. elseif times == 1 then
  2850. times = times + 1
  2851. idleAnimRotX = -0.75
  2852. idleAnimRotZ = -0.75
  2853. elseif times == 2 then
  2854. times = times + 1
  2855. idleAnimRotX = 0
  2856. idleAnimRotZ = -1
  2857. elseif times == 3 then
  2858. times = times + 1
  2859. idleAnimRotX = 0.75
  2860. idleAnimRotZ = -0.75
  2861. --idleAnimRotX = 0.75
  2862. --idleAnimRotZ = -0
  2863. elseif times == 4 then
  2864. times = times + 1
  2865. idleAnimRotX = 1
  2866. idleAnimRotZ = 0
  2867. --idleAnimRotX = 1
  2868. --idleAnimRotZ = 0
  2869. elseif times == 5 then
  2870. times = times + 1
  2871. idleAnimRotX = 0.75
  2872. idleAnimRotZ = 0.75
  2873. elseif times == 6 then
  2874. times = times + 1
  2875. idleAnimRotX = 0
  2876. idleAnimRotZ = 1
  2877. elseif times == 7 then
  2878. times = 0
  2879. idleAnimRotX = -0.75
  2880. idleAnimRotZ = 0.75
  2881. end
  2882. end
  2883.  
  2884. if hi == 1 then hi = 0 end
  2885.  
  2886. local rotX = math.deg(math.atan2(humanoid.MoveDirection.Z, humanoid.MoveDirection.X)) + 90
  2887. if humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
  2888. --print(rotX)
  2889. bodyRot = bodyRot:lerp(CFrame.Angles(0, -math.rad(rotX), 0), 0.125)
  2890. humRootPart.CFrame = CFrame.new(humRootPart.CFrame.p.X, humRootPart.CFrame.p.Y, humRootPart.CFrame.p.Z) * bodyRot
  2891. end
  2892. local neckYRot = math.rad(camPart.Orientation.Y - torso.Orientation.Y)
  2893. neck.C1 = CFrame.new(0, 0.975, 0) * CFrame.fromEulerAnglesXYZ(math.rad(sneaking*45), neckYRot, 0)
  2894. neck.C0 = CFrame.new(0, -0.65, 0) * CFrame.Angles(-math.rad(camPart.Orientation.X - torso.Orientation.X - (sneaking*45)), 0, 0)
  2895.  
  2896. local oldTorsoOrientation = torso.Orientation
  2897. if AngleDifference(camPart.Orientation, torso.Orientation).Y > 45 then
  2898. humRootPart.CFrame = CFrame.new(humRootPart.CFrame.p.X, humRootPart.CFrame.p.Y, humRootPart.CFrame.p.Z) * CFrame.Angles(0, math.rad(head.Orientation.Y + 45), 0)
  2899. bodyRot = CFrame.Angles(0, math.rad(head.Orientation.Y + 45), 0)
  2900. --print("-45")
  2901. elseif AngleDifference(camPart.Orientation, torso.Orientation).Y < -45 then
  2902. humRootPart.CFrame = CFrame.new(humRootPart.CFrame.p.X, humRootPart.CFrame.p.Y, humRootPart.CFrame.p.Z) * CFrame.Angles(0, math.rad(head.Orientation.Y - 45), 0)
  2903. bodyRot = CFrame.Angles(0, math.rad(head.Orientation.Y - 45), 0)
  2904. --print("45")
  2905. end
  2906.  
  2907. lastCamRot = camPart.Orientation
  2908. neck.C1 = neck.C1 * CFrame.fromEulerAnglesXYZ(0, -math.rad(AngleDifference(oldTorsoOrientation, torso.Orientation).Y), 0)
  2909. ticks = ticks + 1
  2910. end
  2911. end
  2912. end
Add Comment
Please, Sign In to add comment