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