Advertisement
Guest User

Untitled

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