doryna2281337

Untitled

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