Advertisement
affady65

Untitled

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