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