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