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