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