View difference between Paste ID: kWmpKY1a and N3NMVQtk
SHOW: | | - or go back to the newest paste.
1
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2
local Player,Mouse,mouse,UserInputService,ContextActionService = owner
3
do
4
	print("FE Compatibility code by Mokiros")
5
	script.Parent = Player.Character
6
7
	--RemoteEvent for communicating
8
	local Event = Instance.new("RemoteEvent")
9
	Event.Name = "UserInput_Event"
10
11
	--Fake event to make stuff like Mouse.KeyDown work
12
	local function fakeEvent()
13
		local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
14
		t.connect = t.Connect
15
		return t
16
	end
17
18
	--Creating fake input objects with fake variables
19
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
20
	local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
21
	local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
22
		CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
23
	end}
24
	--Merged 2 functions into one by checking amount of arguments
25
	CAS.UnbindAction = CAS.BindAction
26
27
	--This function will trigger the events that have been :Connect()'ed
28
	local function te(self,ev,...)
29
		local t = m[ev]
30
		if t and t._fakeEvent and t.Function then
31
			t.Function(...)
32
		end
33
	end
34
	m.TrigEvent = te
35
	UIS.TrigEvent = te
36
37
	Event.OnServerEvent:Connect(function(plr,io)
38
	    if plr~=Player then return end
39
		if io.isMouse then
40
			m.Target = io.Target
41
			m.Hit = io.Hit
42
		else
43
			local b = io.UserInputState == Enum.UserInputState.Begin
44
			if io.UserInputType == Enum.UserInputType.MouseButton1 then
45
				return m:TrigEvent(b and "Button1Down" or "Button1Up")
46
			end
47
			for _,t in pairs(CAS.Actions) do
48
				for _,k in pairs(t.Keys) do
49
					if k==io.KeyCode then
50
						t.Function(t.Name,io.UserInputState,io)
51
					end
52
				end
53
			end
54
			m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
55
			UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
56
	    end
57
	end)
58
	Event.Parent = NLS([==[
59-
	local Player = game:GetService("Players").LocalPlayer
59+
	local Player = owner
60
	local Event = script:WaitForChild("UserInput_Event")
61
62
	local UIS = game:GetService("UserInputService")
63
	local input = function(io,a)
64
		if a then return end
65
		--Since InputObject is a client-side instance, we create and pass table instead
66
		Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
67
	end
68
	UIS.InputBegan:Connect(input)
69
	UIS.InputEnded:Connect(input)
70
71
	local Mouse = Player:GetMouse()
72
	local h,t
73
	--Give the server mouse data 30 times every second, but only if the values changed
74
	--If player is not moving their mouse, client won't fire events
75
	while wait(1/30) do
76
		if h~=Mouse.Hit or t~=Mouse.Target then
77
			h,t=Mouse.Hit,Mouse.Target
78
			Event:FireServer({isMouse=true,Target=t,Hit=h})
79
		end
80
	end]==],Player.Character)
81
	Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
82
end
83
84
85
--Converted with ttyyuu12345's model to script plugin v4
86
function sandbox(var,func)
87
	local env = getfenv(func)
88
	local newenv = setmetatable({},{
89
		__index = function(self,k)
90
			if k=="script" then
91
				return var
92
			else
93
				return env[k]
94
			end
95
		end,
96
	})
97
	setfenv(func,newenv)
98
	return func
99
end
100
cors = {}
101
mas = Instance.new("Model",game:GetService("Lighting"))
102
Model0 = Instance.new("Model")
103
Part1 = Instance.new("Part")
104
Decal2 = Instance.new("Decal")
105
Sound3 = Instance.new("Sound")
106
Sound4 = Instance.new("Sound")
107
Sound5 = Instance.new("Sound")
108
Sound6 = Instance.new("Sound")
109
Sound7 = Instance.new("Sound")
110
Sound8 = Instance.new("Sound")
111
Sound9 = Instance.new("Sound")
112
Sound10 = Instance.new("Sound")
113
Sound11 = Instance.new("Sound")
114
CylinderMesh12 = Instance.new("CylinderMesh")
115
Part13 = Instance.new("Part")
116
Decal14 = Instance.new("Decal")
117
Motor6D15 = Instance.new("Motor6D")
118
Motor6D16 = Instance.new("Motor6D")
119
Motor6D17 = Instance.new("Motor6D")
120
Motor6D18 = Instance.new("Motor6D")
121
Motor6D19 = Instance.new("Motor6D")
122
Part20 = Instance.new("Part")
123
Part21 = Instance.new("Part")
124
Part22 = Instance.new("Part")
125
Part23 = Instance.new("Part")
126
Humanoid24 = Instance.new("Humanoid")
127
Part25 = Instance.new("Part")
128
Motor6D26 = Instance.new("Motor6D")
129
Script27 = Instance.new("Script")
130
LocalScript28 = Instance.new("LocalScript")
131
LocalScript29 = Instance.new("LocalScript")
132
StringValue30 = Instance.new("StringValue")
133
Animation31 = Instance.new("Animation")
134
NumberValue32 = Instance.new("NumberValue")
135
Animation33 = Instance.new("Animation")
136
NumberValue34 = Instance.new("NumberValue")
137
StringValue35 = Instance.new("StringValue")
138
Animation36 = Instance.new("Animation")
139
StringValue37 = Instance.new("StringValue")
140
Animation38 = Instance.new("Animation")
141
StringValue39 = Instance.new("StringValue")
142
Animation40 = Instance.new("Animation")
143
StringValue41 = Instance.new("StringValue")
144
Animation42 = Instance.new("Animation")
145
StringValue43 = Instance.new("StringValue")
146
Animation44 = Instance.new("Animation")
147
StringValue45 = Instance.new("StringValue")
148
Animation46 = Instance.new("Animation")
149
StringValue47 = Instance.new("StringValue")
150
Animation48 = Instance.new("Animation")
151
Script49 = Instance.new("Script")
152
BodyColors50 = Instance.new("BodyColors")
153
Model0.Name = "oii"
154
Model0.Parent = mas
155
Part1.Name = "Head"
156
Part1.Parent = Model0
157
Part1.CFrame = CFrame.new(13.7936363, 4.50001431, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
158
Part1.Orientation = Vector3.new(0, -6.40999985, 0)
159
Part1.Position = Vector3.new(13.7936363, 4.50001431, -22.1235237)
160
Part1.Rotation = Vector3.new(0, -6.40999985, 0)
161
Part1.Color = Color3.new(0.803922, 0, 0)
162
Part1.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
163
Part1.Size = Vector3.new(2, 1, 1)
164
Part1.BrickColor = BrickColor.new("Really red")
165
Part1.Locked = true
166
Part1.TopSurface = Enum.SurfaceType.Smooth
167
Part1.brickColor = BrickColor.new("Really red")
168
Part1.FormFactor = Enum.FormFactor.Symmetric
169
Part1.formFactor = Enum.FormFactor.Symmetric
170
Decal2.Name = "face"
171
Decal2.Parent = Part1
172
Decal2.Texture = "rbxasset://textures/face.png"
173
Sound3.Name = "GettingUp"
174
Sound3.Parent = Part1
175
Sound3.MaxDistance = 150
176
Sound3.EmitterSize = 5
177
Sound3.MinDistance = 5
178
Sound3.SoundId = "rbxasset://sounds/action_get_up.mp3"
179
Sound3.Volume = 0.64999997615814
180
Sound4.Name = "Died"
181
Sound4.Parent = Part1
182
Sound4.MaxDistance = 150
183
Sound4.EmitterSize = 5
184
Sound4.MinDistance = 5
185
Sound4.SoundId = "rbxasset://sounds/uuhhh.mp3"
186
Sound4.Volume = 0.64999997615814
187
Sound5.Name = "FreeFalling"
188
Sound5.Parent = Part1
189
Sound5.Looped = true
190
Sound5.TimePosition = 0.52838909903676
191
Sound5.MaxDistance = 150
192
Sound5.EmitterSize = 5
193
Sound5.MinDistance = 5
194
Sound5.SoundId = "rbxasset://sounds/action_falling.mp3"
195
Sound5.Volume = 0
196
Sound6.Name = "Jumping"
197
Sound6.Parent = Part1
198
Sound6.MaxDistance = 150
199
Sound6.EmitterSize = 5
200
Sound6.MinDistance = 5
201
Sound6.SoundId = "rbxasset://sounds/action_jump.mp3"
202
Sound6.Volume = 0.64999997615814
203
Sound7.Name = "Landing"
204
Sound7.Parent = Part1
205
Sound7.MaxDistance = 150
206
Sound7.EmitterSize = 5
207
Sound7.MinDistance = 5
208
Sound7.SoundId = "rbxasset://sounds/action_jump_land.mp3"
209
Sound7.Volume = 1
210
Sound8.Name = "Splash"
211
Sound8.Parent = Part1
212
Sound8.MaxDistance = 150
213
Sound8.EmitterSize = 5
214
Sound8.MinDistance = 5
215
Sound8.SoundId = "rbxasset://sounds/impact_water.mp3"
216
Sound8.Volume = 0.64999997615814
217
Sound9.Name = "Running"
218
Sound9.Parent = Part1
219
Sound9.Looped = true
220
Sound9.TimePosition = 1.7229757305085
221
Sound9.MaxDistance = 150
222
Sound9.EmitterSize = 5
223
Sound9.MinDistance = 5
224
Sound9.Pitch = 1.8500000238419
225
Sound9.PlaybackSpeed = 1.8500000238419
226
Sound9.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
227
Sound9.Volume = 0.64999997615814
228
Sound10.Name = "Swimming"
229
Sound10.Parent = Part1
230
Sound10.Looped = true
231
Sound10.MaxDistance = 150
232
Sound10.EmitterSize = 5
233
Sound10.MinDistance = 5
234
Sound10.Pitch = 1.6000000238419
235
Sound10.PlaybackSpeed = 1.6000000238419
236
Sound10.SoundId = "rbxasset://sounds/action_swim.mp3"
237
Sound10.Volume = 0.64999997615814
238
Sound11.Name = "Climbing"
239
Sound11.Parent = Part1
240
Sound11.Looped = true
241
Sound11.MaxDistance = 150
242
Sound11.EmitterSize = 5
243
Sound11.MinDistance = 5
244
Sound11.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
245
Sound11.Volume = 0.64999997615814
246
CylinderMesh12.Parent = Part1
247
CylinderMesh12.Scale = Vector3.new(1.29999995, 1.29999995, 1.29999995)
248
Part13.Name = "Torso"
249
Part13.Parent = Model0
250
Part13.CFrame = CFrame.new(13.7936363, 3.00001407, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
251
Part13.Orientation = Vector3.new(0, -6.40999985, 0)
252
Part13.Position = Vector3.new(13.7936363, 3.00001407, -22.1235237)
253
Part13.Rotation = Vector3.new(0, -6.40999985, 0)
254
Part13.Color = Color3.new(1, 1, 0)
255
Part13.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
256
Part13.Size = Vector3.new(2, 2, 1)
257
Part13.BrickColor = BrickColor.new("New Yeller")
258
Part13.LeftParamA = 0
259
Part13.LeftParamB = 0
260
Part13.LeftSurface = Enum.SurfaceType.Weld
261
Part13.Locked = true
262
Part13.RightParamA = 0
263
Part13.RightParamB = 0
264
Part13.RightSurface = Enum.SurfaceType.Weld
265
Part13.brickColor = BrickColor.new("New Yeller")
266
Part13.FormFactor = Enum.FormFactor.Symmetric
267
Part13.formFactor = Enum.FormFactor.Symmetric
268
Decal14.Name = "roblox"
269
Decal14.Parent = Part13
270
Motor6D15.Name = "Right Shoulder"
271
Motor6D15.Parent = Part13
272
Motor6D15.MaxVelocity = 0.10000000149012
273
Motor6D15.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
274
Motor6D15.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
275
Motor6D15.Part0 = Part13
276
Motor6D15.Part1 = Part21
277
Motor6D15.part1 = Part21
278
Motor6D16.Name = "Left Shoulder"
279
Motor6D16.Parent = Part13
280
Motor6D16.MaxVelocity = 0.10000000149012
281
Motor6D16.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
282
Motor6D16.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
283
Motor6D16.Part0 = Part13
284
Motor6D16.Part1 = Part20
285
Motor6D16.part1 = Part20
286
Motor6D17.Name = "Right Hip"
287
Motor6D17.Parent = Part13
288
Motor6D17.MaxVelocity = 0.10000000149012
289
Motor6D17.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
290
Motor6D17.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
291
Motor6D17.Part0 = Part13
292
Motor6D17.Part1 = Part23
293
Motor6D17.part1 = Part23
294
Motor6D18.Name = "Left Hip"
295
Motor6D18.Parent = Part13
296
Motor6D18.MaxVelocity = 0.10000000149012
297
Motor6D18.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
298
Motor6D18.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
299
Motor6D18.Part0 = Part13
300
Motor6D18.Part1 = Part22
301
Motor6D18.part1 = Part22
302
Motor6D19.Name = "Neck"
303
Motor6D19.Parent = Part13
304
Motor6D19.MaxVelocity = 0.10000000149012
305
Motor6D19.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
306
Motor6D19.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
307
Motor6D19.Part0 = Part13
308
Motor6D19.Part1 = Part1
309
Motor6D19.part1 = Part1
310
Part20.Name = "Left Arm"
311
Part20.Parent = Model0
312
Part20.CFrame = CFrame.new(12.3029995, 3.00001407, -22.2908611, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
313
Part20.Orientation = Vector3.new(0, -6.40999985, 0)
314
Part20.Position = Vector3.new(12.3029995, 3.00001407, -22.2908611)
315
Part20.Rotation = Vector3.new(0, -6.40999985, 0)
316
Part20.Color = Color3.new(0.803922, 0, 0)
317
Part20.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
318
Part20.Size = Vector3.new(1, 2, 1)
319
Part20.BrickColor = BrickColor.new("Really red")
320
Part20.CanCollide = false
321
Part20.Locked = true
322
Part20.brickColor = BrickColor.new("Really red")
323
Part20.FormFactor = Enum.FormFactor.Symmetric
324
Part20.formFactor = Enum.FormFactor.Symmetric
325
Part21.Name = "Right Arm"
326
Part21.Parent = Model0
327
Part21.CFrame = CFrame.new(15.2842731, 3.00001407, -21.9561863, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
328
Part21.Orientation = Vector3.new(0, -6.40999985, 0)
329
Part21.Position = Vector3.new(15.2842731, 3.00001407, -21.9561863)
330
Part21.Rotation = Vector3.new(0, -6.40999985, 0)
331
Part21.Color = Color3.new(0.803922, 0, 0)
332
Part21.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
333
Part21.Size = Vector3.new(1, 2, 1)
334
Part21.BrickColor = BrickColor.new("Really red")
335
Part21.CanCollide = false
336
Part21.Locked = true
337
Part21.brickColor = BrickColor.new("Really red")
338
Part21.FormFactor = Enum.FormFactor.Symmetric
339
Part21.formFactor = Enum.FormFactor.Symmetric
340
Part22.Name = "Left Leg"
341
Part22.Parent = Model0
342
Part22.CFrame = CFrame.new(13.2967577, 1.00001407, -22.1793022, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
343
Part22.Orientation = Vector3.new(0, -6.40999985, 0)
344
Part22.Position = Vector3.new(13.2967577, 1.00001407, -22.1793022)
345
Part22.Rotation = Vector3.new(0, -6.40999985, 0)
346
Part22.Color = Color3.new(1, 1, 0)
347
Part22.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
348
Part22.Size = Vector3.new(1, 2, 1)
349
Part22.BottomSurface = Enum.SurfaceType.Smooth
350
Part22.BrickColor = BrickColor.new("New Yeller")
351
Part22.CanCollide = false
352
Part22.Locked = true
353
Part22.brickColor = BrickColor.new("New Yeller")
354
Part22.FormFactor = Enum.FormFactor.Symmetric
355
Part22.formFactor = Enum.FormFactor.Symmetric
356
Part23.Name = "Right Leg"
357
Part23.Parent = Model0
358
Part23.CFrame = CFrame.new(14.2905149, 1.00001407, -22.0677452, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
359
Part23.Orientation = Vector3.new(0, -6.40999985, 0)
360
Part23.Position = Vector3.new(14.2905149, 1.00001407, -22.0677452)
361
Part23.Rotation = Vector3.new(0, -6.40999985, 0)
362
Part23.Color = Color3.new(1, 1, 0)
363
Part23.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
364
Part23.Size = Vector3.new(1, 2, 1)
365
Part23.BottomSurface = Enum.SurfaceType.Smooth
366
Part23.BrickColor = BrickColor.new("New Yeller")
367
Part23.CanCollide = false
368
Part23.Locked = true
369
Part23.brickColor = BrickColor.new("New Yeller")
370
Part23.FormFactor = Enum.FormFactor.Symmetric
371
Part23.formFactor = Enum.FormFactor.Symmetric
372
Humanoid24.Parent = Model0
373
Humanoid24.LeftLeg = Part22
374
Humanoid24.RightLeg = Part23
375
Humanoid24.Torso = Part25
376
Part25.Name = "HumanoidRootPart"
377
Part25.Parent = Model0
378
Part25.CFrame = CFrame.new(13.7936363, 3.00001407, -22.1235237, 0.993757904, 0, -0.111558832, 0, 1, 0, 0.111558832, 0, 0.993757904)
379
Part25.Orientation = Vector3.new(0, -6.40999985, 0)
380
Part25.Position = Vector3.new(13.7936363, 3.00001407, -22.1235237)
381
Part25.Rotation = Vector3.new(0, -6.40999985, 0)
382
Part25.Transparency = 1
383
Part25.Velocity = Vector3.new(5.33474325e-42, 0, -4.77520478e-41)
384
Part25.Size = Vector3.new(2, 2, 1)
385
Part25.BottomSurface = Enum.SurfaceType.Smooth
386
Part25.CanCollide = false
387
Part25.LeftParamA = 0
388
Part25.LeftParamB = 0
389
Part25.Locked = true
390
Part25.RightParamA = 0
391
Part25.RightParamB = 0
392
Part25.TopSurface = Enum.SurfaceType.Smooth
393
Part25.FormFactor = Enum.FormFactor.Symmetric
394
Part25.formFactor = Enum.FormFactor.Symmetric
395
Motor6D26.Name = "RootJoint"
396
Motor6D26.Parent = Part25
397
Motor6D26.MaxVelocity = 0.10000000149012
398
Motor6D26.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
399
Motor6D26.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
400
Motor6D26.Part0 = Part25
401
Motor6D26.Part1 = Part13
402
Motor6D26.part1 = Part13
403
Script27.Name = "Sound"
404
Script27.Parent = Model0
405
table.insert(cors,sandbox(Script27,function()
406
--[[
407
	Author: @spotco
408
	This script creates sounds which are placed under the character head.
409
	These sounds are used by the "LocalSound" script.
410
	
411
	To modify this script, copy it to your "StarterPlayer/StarterCharacterScripts" folder keeping the same script name ("Sound").
412
	The default Sound script loaded for every character will then be replaced with your copy of the script.
413
]]--
414
415
function CreateNewSound(name, id, looped, pitch, parent)
416
	local sound = Instance.new("Sound")
417
	sound.SoundId = id
418
	sound.Name = name
419
	sound.archivable = false
420
	sound.Parent = parent
421
	sound.Pitch = pitch
422
	sound.Looped = looped
423
	
424
	sound.MinDistance = 5
425
	sound.MaxDistance = 150
426
	sound.Volume = 0.65
427
	
428
	return sound
429
end
430
431
local head = script.Parent:FindFirstChild("Head")
432
if head == nil then
433
	error("Sound script parent has no child Head.")
434
	return
435
end
436
437
438
CreateNewSound("GettingUp", 	"rbxasset://sounds/action_get_up.mp3",					false, 	1,		head)
439
CreateNewSound("Died", 		"rbxasset://sounds/uuhhh.mp3",							false, 	1,		head) 
440
CreateNewSound("FreeFalling", 	"rbxasset://sounds/action_falling.mp3",				true,	1,		head)
441
CreateNewSound("Jumping", 		"rbxasset://sounds/action_jump.mp3",					false,	1,		head)
442
CreateNewSound("Landing", 		"rbxasset://sounds/action_jump_land.mp3",				false,	1,		head)
443
CreateNewSound("Splash", 		"rbxasset://sounds/impact_water.mp3",					false, 	1,		head)
444
CreateNewSound("Running", 		"rbxasset://sounds/action_footsteps_plastic.mp3",		true, 	1.85,	head)
445
CreateNewSound("Swimming", 	"rbxasset://sounds/action_swim.mp3",					true,	1.6,	head)
446
CreateNewSound("Climbing", 	"rbxasset://sounds/action_footsteps_plastic.mp3",		true,	1,		head)
447
end))
448
LocalScript28.Name = "LocalSound"
449
LocalScript28.Parent = Script27
450
table.insert(cors,sandbox(LocalScript28,function()
451
--[[
452
	Author: @spotco
453
	This script runs locally for the player of the given humanoid.
454
	This script triggers humanoid sound play/pause actions locally.
455
	
456
	The Playing/TimePosition properties of Sound objects bypass FilteringEnabled, so this triggers the sound
457
	immediately for the player and is replicated to all other players.
458
	
459
	This script is optimized to reduce network traffic through minimizing the amount of property replication.
460
]]--
461
462
--All sounds are referenced by this ID
463
local SFX = {
464
	Died = 0;
465
	Running = 1;
466
	Swimming = 2;
467
	Climbing = 3,
468
	Jumping = 4;
469
	GettingUp = 5;
470
	FreeFalling = 6;
471
	FallingDown = 7;
472
	Landing = 8;
473
	Splash = 9;
474
}
475
476
local Humanoid = nil
477
local Head = nil
478
479
--SFX ID to Sound object
480
local Sounds = {}
481
482
do
483
	local Figure = script.Parent.Parent
484
	Head = Figure:WaitForChild("Head")
485
	while not Humanoid do
486
		for _,NewHumanoid in pairs(Figure:GetChildren()) do
487
			if NewHumanoid:IsA("Humanoid") then
488
				Humanoid = NewHumanoid
489
				break
490
			end
491
		end
492
		Figure.ChildAdded:wait()
493
	end
494
	
495
	Sounds[SFX.Died] = 			Head:WaitForChild("Died")
496
	Sounds[SFX.Running] = 		Head:WaitForChild("Running")
497
	Sounds[SFX.Swimming] = 	Head:WaitForChild("Swimming")
498
	Sounds[SFX.Climbing] = 	Head:WaitForChild("Climbing")
499
	Sounds[SFX.Jumping] = 		Head:WaitForChild("Jumping")
500
	Sounds[SFX.GettingUp] = 	Head:WaitForChild("GettingUp")
501
	Sounds[SFX.FreeFalling] = 	Head:WaitForChild("FreeFalling")
502
	Sounds[SFX.Landing] = 		Head:WaitForChild("Landing")
503
	Sounds[SFX.Splash] = 		Head:WaitForChild("Splash")
504
end
505
506
local Util
507
Util = {
508
	
509
	--Define linear relationship between (pt1x,pt2x) and (pt2x,pt2y). Evaluate this at x.
510
	YForLineGivenXAndTwoPts = function(x,pt1x,pt1y,pt2x,pt2y)
511
		--(y - y1)/(x - x1) = m
512
		local m = (pt1y - pt2y) / (pt1x - pt2x)
513
		--float b = pt1.y - m * pt1.x;
514
		local b = (pt1y - m * pt1x)
515
		return m * x + b
516
	end;
517
	
518
	--Clamps the value of "val" between the "min" and "max"
519
	Clamp = function(val,min,max)
520
		return math.min(max,math.max(min,val))	
521
	end;
522
	
523
	--Gets the horizontal (x,z) velocity magnitude of the given part
524
	HorizontalSpeed = function(Head)
525
		local hVel = Head.Velocity + Vector3.new(0,-Head.Velocity.Y,0)
526
		return hVel.magnitude	
527
	end;
528
	
529
	--Gets the vertical (y) velocity magnitude of the given part
530
	VerticalSpeed = function(Head)
531
		return math.abs(Head.Velocity.Y)
532
	end;
533
	
534
	--Setting Playing/TimePosition values directly result in less network traffic than Play/Pause/Resume/Stop
535
	--If these properties are enabled, use them.
536
	Play = function(sound)		
537
		if sound.TimePosition ~= 0 then
538
			sound.TimePosition = 0
539
		end
540
		if not sound.IsPlaying then
541
			sound.Playing = true
542
		end
543
	end;
544
	Pause = function(sound)
545
		if sound.IsPlaying then
546
			sound.Playing = false
547
		end
548
	end;
549
	Resume = function(sound)
550
		if not sound.IsPlaying then
551
			sound.Playing = true
552
		end
553
	end;
554
	Stop = function(sound)
555
		if sound.IsPlaying then
556
			sound.Playing = false
557
		end
558
		if sound.TimePosition ~= 0 then
559
			sound.TimePosition = 0
560
		end
561
	end;
562
}
563
564
do
565
	-- List of all active Looped sounds
566
	local playingLoopedSounds = {}
567
	
568
	-- Last seen Enum.HumanoidStateType
569
	local activeState = nil
570
	
571
	-- Verify and set that "sound" is in "playingLoopedSounds".
572
	function setSoundInPlayingLoopedSounds(sound)
573
		for i=1, #playingLoopedSounds do
574
			if playingLoopedSounds[i] == sound then
575
				return
576
			end
577
		end	
578
		table.insert(playingLoopedSounds,sound)
579
	end
580
	
581
	-- Stop all active looped sounds except parameter "except". If "except" is not passed, all looped sounds will be stopped.
582
	function stopPlayingLoopedSoundsExcept(except)
583
		for i=#playingLoopedSounds,1,-1 do
584
			if playingLoopedSounds[i] ~= except then
585
				Util.Pause(playingLoopedSounds[i])			
586
				table.remove(playingLoopedSounds,i)	
587
			end
588
		end
589
	end
590
	
591
	-- Table of Enum.HumanoidStateType to handling function
592
	local stateUpdateHandler = {
593
		[Enum.HumanoidStateType.Dead] = function()
594
			stopPlayingLoopedSoundsExcept()
595
			local sound = Sounds[SFX.Died]
596
			Util.Play(sound)
597
		end;
598
		
599
		[Enum.HumanoidStateType.RunningNoPhysics] = function()
600
			stateUpdated(Enum.HumanoidStateType.Running)
601
		end;
602
		
603
		[Enum.HumanoidStateType.Running] = function()	
604
			local sound = Sounds[SFX.Running]
605
			stopPlayingLoopedSoundsExcept(sound)
606
			
607
			if Util.HorizontalSpeed(Head) > 0.5 then
608
				Util.Resume(sound)
609
				setSoundInPlayingLoopedSounds(sound)
610
			else
611
				stopPlayingLoopedSoundsExcept()
612
			end
613
		end;
614
		
615
		[Enum.HumanoidStateType.Swimming] = function()
616
			if activeState ~= Enum.HumanoidStateType.Swimming and Util.VerticalSpeed(Head) > 0.1 then
617
				local splashSound = Sounds[SFX.Splash]
618
				splashSound.Volume = Util.Clamp(
619
					Util.YForLineGivenXAndTwoPts(
620
						Util.VerticalSpeed(Head), 
621
						100, 0.28, 
622
						350, 1),
623
					0,1)
624
				Util.Play(splashSound)
625
			end
626
			
627
			do
628
				local sound = Sounds[SFX.Swimming]
629
				stopPlayingLoopedSoundsExcept(sound)
630
				Util.Resume(sound)
631
				setSoundInPlayingLoopedSounds(sound)
632
			end
633
		end;
634
		
635
		[Enum.HumanoidStateType.Climbing] = function()
636
			local sound = Sounds[SFX.Climbing]
637
			if Util.VerticalSpeed(Head) > 0.1 then
638
				Util.Resume(sound)
639
				stopPlayingLoopedSoundsExcept(sound)
640
			else
641
				stopPlayingLoopedSoundsExcept()
642
			end		
643
			setSoundInPlayingLoopedSounds(sound)
644
		end;
645
		
646
		[Enum.HumanoidStateType.Jumping] = function()
647
			if activeState == Enum.HumanoidStateType.Jumping then
648
				return
649
			end		
650
			stopPlayingLoopedSoundsExcept()
651
			local sound = Sounds[SFX.Jumping]
652
			Util.Play(sound)
653
		end;
654
		
655
		[Enum.HumanoidStateType.GettingUp] = function()
656
			stopPlayingLoopedSoundsExcept()
657
			local sound = Sounds[SFX.GettingUp]
658
			Util.Play(sound)
659
		end;
660
		
661
		[Enum.HumanoidStateType.Freefall] = function()
662
			if activeState == Enum.HumanoidStateType.Freefall then
663
				return
664
			end
665
			local sound = Sounds[SFX.FreeFalling]
666
			sound.Volume = 0
667
			stopPlayingLoopedSoundsExcept()
668
		end;
669
		
670
		[Enum.HumanoidStateType.FallingDown] = function()
671
			stopPlayingLoopedSoundsExcept()
672
		end;
673
		
674
		[Enum.HumanoidStateType.Landed] = function()
675
			stopPlayingLoopedSoundsExcept()
676
			if Util.VerticalSpeed(Head) > 75 then
677
				local landingSound = Sounds[SFX.Landing]
678
				landingSound.Volume = Util.Clamp(
679
					Util.YForLineGivenXAndTwoPts(
680
						Util.VerticalSpeed(Head), 
681
						50, 0, 
682
						100, 1),
683
					0,1)
684
				Util.Play(landingSound)			
685
			end
686
		end;
687
		
688
		[Enum.HumanoidStateType.Seated] = function()
689
			stopPlayingLoopedSoundsExcept()
690
		end;	
691
	}
692
	
693
	-- Handle state event fired or OnChange fired
694
	function stateUpdated(state)
695
		if stateUpdateHandler[state] ~= nil then
696
			stateUpdateHandler[state]()
697
		end
698
		activeState = state
699
	end
700
	
701
	Humanoid.Died:connect(			function() stateUpdated(Enum.HumanoidStateType.Dead) 			end)
702
	Humanoid.Running:connect(		function() stateUpdated(Enum.HumanoidStateType.Running) 		end)
703
	Humanoid.Swimming:connect(		function() stateUpdated(Enum.HumanoidStateType.Swimming) 		end)
704
	Humanoid.Climbing:connect(		function() stateUpdated(Enum.HumanoidStateType.Climbing) 		end)
705
	Humanoid.Jumping:connect(		function() stateUpdated(Enum.HumanoidStateType.Jumping) 		end)
706
	Humanoid.GettingUp:connect(		function() stateUpdated(Enum.HumanoidStateType.GettingUp) 		end)
707
	Humanoid.FreeFalling:connect(		function() stateUpdated(Enum.HumanoidStateType.Freefall) 		end)
708
	Humanoid.FallingDown:connect(		function() stateUpdated(Enum.HumanoidStateType.FallingDown) 	end)
709
	
710
	-- required for proper handling of Landed event
711
	Humanoid.StateChanged:connect(function(old, new)
712
		stateUpdated(new)
713
	end)
714
	
715
	
716
	function onUpdate(stepDeltaSeconds, tickSpeedSeconds)
717
		local stepScale = stepDeltaSeconds / tickSpeedSeconds
718
		do
719
			local sound = Sounds[SFX.FreeFalling]
720
			if activeState == Enum.HumanoidStateType.Freefall then
721
				if Head.Velocity.Y < 0 and Util.VerticalSpeed(Head) > 75 then
722
					Util.Resume(sound)
723
					
724
					--Volume takes 1.1 seconds to go from volume 0 to 1
725
					local ANIMATION_LENGTH_SECONDS = 1.1
726
					
727
					local normalizedIncrement = tickSpeedSeconds / ANIMATION_LENGTH_SECONDS									
728
					sound.Volume = Util.Clamp(sound.Volume + normalizedIncrement * stepScale, 0, 1)
729
				else
730
					sound.Volume = 0
731
				end			
732
			else
733
				Util.Pause(sound)
734
			end
735
		end
736
		
737
		do
738
			local sound = Sounds[SFX.Running]
739
			if activeState == Enum.HumanoidStateType.Running then
740
				if Util.HorizontalSpeed(Head) < 0.5 then
741
					Util.Pause(sound)
742
				end
743
			end
744
		end		
745
	end
746
	
747
	local lastTick = tick()
748
	local TICK_SPEED_SECONDS = 0.25
749
	while true do
750
		onUpdate(tick() - lastTick,TICK_SPEED_SECONDS)
751
		lastTick = tick()
752
		wait(TICK_SPEED_SECONDS)
753
	end
754
end
755
756
end))
757
LocalScript29.Name = "Animate"
758
LocalScript29.Parent = Model0
759
table.insert(cors,sandbox(LocalScript29,function()
760
function   waitForChild(parent, childName)
761
	local child = parent:findFirstChild(childName)
762
	if child then return child end
763
	while true do
764
		child = parent.ChildAdded:wait()
765
		if child.Name==childName then return child end
766
	end
767
end
768
769
local Figure = script.Parent
770
local Torso = waitForChild(Figure, "Torso")
771
local RightShoulder = waitForChild(Torso, "Right Shoulder")
772
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
773
local RightHip = waitForChild(Torso, "Right Hip")
774
local LeftHip = waitForChild(Torso, "Left Hip")
775
local Neck = waitForChild(Torso, "Neck")
776
local Humanoid = waitForChild(Figure, "Humanoid")
777
local pose = "Standing"
778
779
local currentAnim = ""
780
local currentAnimInstance = nil
781
local currentAnimTrack = nil
782
local currentAnimKeyframeHandler = nil
783
local currentAnimSpeed = 1.0
784
local animTable = {}
785
local animNames = { 
786
	idle = 	{	
787
				{ id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
788
				{ id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
789
			},
790
	walk = 	{ 	
791
				{ id = "http://www.roblox.com/asset/?id=180426354", weight = 10 } 
792
			}, 
793
	run = 	{
794
				{ id = "run.xml", weight = 10 } 
795
			}, 
796
	jump = 	{
797
				{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 } 
798
			}, 
799
	fall = 	{
800
				{ id = "http://www.roblox.com/asset/?id=180436148", weight = 10 } 
801
			}, 
802
	climb = {
803
				{ id = "http://www.roblox.com/asset/?id=180436334", weight = 10 } 
804
			}, 
805
	sit = 	{
806
				{ id = "http://www.roblox.com/asset/?id=178130996", weight = 10 } 
807
			},	
808
	toolnone = {
809
				{ id = "http://www.roblox.com/asset/?id=182393478", weight = 10 } 
810
			},
811
	toolslash = {
812
				{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 } 
813
--				{ id = "slash.xml", weight = 10 } 
814
			},
815
	toollunge = {
816
				{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 } 
817
			},
818
	wave = {
819
				{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 } 
820
			},
821
	point = {
822
				{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 } 
823
			},
824
	dance1 = {
825
				{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 }, 
826
				{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 }, 
827
				{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 } 
828
			},
829
	dance2 = {
830
				{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 }, 
831
				{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 }, 
832
				{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 } 
833
			},
834
	dance3 = {
835
				{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 }, 
836
				{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 }, 
837
				{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 } 
838
			},
839
	laugh = {
840
				{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 } 
841
			},
842
	cheer = {
843
				{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 } 
844
			},
845
}
846
local dances = {"dance1", "dance2", "dance3"}
847
848
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
849
local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
850
851
function configureAnimationSet(name, fileList)
852
	if (animTable[name] ~= nil) then
853
		for _, connection in pairs(animTable[name].connections) do
854
			connection:disconnect()
855
		end
856
	end
857
	animTable[name] = {}
858
	animTable[name].count = 0
859
	animTable[name].totalWeight = 0	
860
	animTable[name].connections = {}
861
862
	-- check for config values
863
	local config = script:FindFirstChild(name)
864
	if (config ~= nil) then
865
--		print("Loading anims " .. name)
866
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
867
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
868
		local idx = 1
869
		for _, childPart in pairs(config:GetChildren()) do
870
			if (childPart:IsA("Animation")) then
871
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
872
				animTable[name][idx] = {}
873
				animTable[name][idx].anim = childPart
874
				local weightObject = childPart:FindFirstChild("Weight")
875
				if (weightObject == nil) then
876
					animTable[name][idx].weight = 1
877
				else
878
					animTable[name][idx].weight = weightObject.Value
879
				end
880
				animTable[name].count = animTable[name].count + 1
881
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
882
	--			print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
883
				idx = idx + 1
884
			end
885
		end
886
	end
887
888
	-- fallback to defaults
889
	if (animTable[name].count <= 0) then
890
		for idx, anim in pairs(fileList) do
891
			animTable[name][idx] = {}
892
			animTable[name][idx].anim = Instance.new("Animation")
893
			animTable[name][idx].anim.Name = name
894
			animTable[name][idx].anim.AnimationId = anim.id
895
			animTable[name][idx].weight = anim.weight
896
			animTable[name].count = animTable[name].count + 1
897
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
898
--			print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
899
		end
900
	end
901
end
902
903
-- Setup animation objects
904
905
function Eviscerate(dude)
906
cam = game.Workspace.CurrentCamera
907
CF = CFrame.new
908
angles = CFrame.Angles
909
attack = false
910
Euler = CFrame.fromEulerAnglesXYZ
911
Rad = math.rad
912
IT = Instance.new
913
BrickC = BrickColor.new
914
Cos = math.cos
915
Acos = math.acos
916
Sin = math.sin
917
Asin = math.asin
918
Abs = math.abs
919
Mrandom = math.random
920
Floor = math.floor
921
	if dude.Name ~= char then
922
		local bgf = IT("BodyGyro", dude.Head)
923
		bgf.CFrame = bgf.CFrame * CFrame.fromEulerAnglesXYZ(Rad(-50), 0, 0)
924
		local val = IT("BoolValue", dude)
925
		val.Name = "IsHit"
926
		local ds = coroutine.wrap(function()
927
			dude:WaitForChild("Head"):BreakJoints()
928
			wait(0.5)
929
			target = nil
930
			coroutine.resume(coroutine.create(function()
931
				for i, v in pairs(dude:GetChildren()) do
932
					if v:IsA("Accessory") then
933
						v:Destroy()
934
					end
935
					if v:IsA("Humanoid") then
936
						v:Destroy()
937
					end
938
					if v:IsA("CharacterMesh") then
939
						v:Destroy()
940
					end
941
					if v:IsA("Model") then
942
						v:Destroy()
943
					end
944
					if v:IsA("Part") or v:IsA("MeshPart") then
945
						for x, o in pairs(v:GetChildren()) do
946
							if o:IsA("Decal") then
947
								o:Destroy()
948
							end
949
						end
950
						coroutine.resume(coroutine.create(function()
951
							v.Material = "Neon"
952
							v.CanCollide = false
953
							local PartEmmit1 = IT("ParticleEmitter", v)
954
							PartEmmit1.LightEmission = 1
955
							PartEmmit1.Texture = "rbxassetid://0"
956
							PartEmmit1.Color = ColorSequence.new(maincolor.Color)
957
							PartEmmit1.Rate = 150
958
							PartEmmit1.Lifetime = NumberRange.new(1)
959
							PartEmmit1.Size = NumberSequence.new({
960
								NumberSequenceKeypoint.new(0, 0.75, 0),
961
								NumberSequenceKeypoint.new(1, 0, 0)
962
							})
963
							PartEmmit1.Transparency = NumberSequence.new({
964
								NumberSequenceKeypoint.new(0, 0, 0),
965
								NumberSequenceKeypoint.new(1, 1, 0)
966
							})
967
							PartEmmit1.Speed = NumberRange.new(0, 0)
968
							PartEmmit1.VelocitySpread = 30000
969
							PartEmmit1.Rotation = NumberRange.new(-500, 500)
970
							PartEmmit1.RotSpeed = NumberRange.new(-500, 500)
971
							local BodPoss = IT("BodyPosition", v)
972
							BodPoss.P = 3000
973
							BodPoss.D = 1000
974
							BodPoss.maxForce = Vector3.new(50000000000, 50000000000, 50000000000)
975
							BodPoss.position = v.Position + Vector3.new(Mrandom(-15, 15), Mrandom(-15, 15), Mrandom(-15, 15))
976
							v.Color = maincolor.Color
977
							coroutine.resume(coroutine.create(function()
978
								for i = 0, 49 do
979
									swait(1)
980
									v.Transparency = v.Transparency + 0.08
981
								end
982
								wait(0.5)
983
								PartEmmit1.Enabled = false
984
								wait(3)
985
								v:Destroy()
986
								dude:Destroy()
987
							end))
988
						end))
989
					end
990
				end
991
			end))
992
		end)
993
		ds()
994
	end
995
end
996
997
function FindNearestHead(Position, Distance, SinglePlayer)
998
	if SinglePlayer then
999
		return Distance > (SinglePlayer.Torso.CFrame.p - Position).magnitude
1000
	end
1001
	local List = {}
1002
	for i, v in pairs(workspace:GetChildren()) do
1003
		if v:IsA("Model") and v:findFirstChild("Head") and v ~= char and Distance >= (v.Head.Position - Position).magnitude then
1004
			table.insert(List, v)
1005
		end
1006
	end
1007
	return List
1008
end
1009
function scriptChildModified(child)
1010
	local fileList = animNames[child.Name]
1011
	if (fileList ~= nil) then
1012
		configureAnimationSet(child.Name, fileList)
1013
	end	
1014
end
1015
1016
script.ChildAdded:connect(scriptChildModified)
1017
script.ChildRemoved:connect(scriptChildModified)
1018
1019
1020
for name, fileList in pairs(animNames) do 
1021
	configureAnimationSet(name, fileList)
1022
end	
1023
1024
-- ANIMATION
1025
1026
-- declarations
1027
local toolAnim = "None"
1028
local toolAnimTime = 0
1029
1030
local jumpAnimTime = 0
1031
local jumpAnimDuration = 0.3
1032
1033
local toolTransitionTime = 0.1
1034
local fallTransitionTime = 0.3
1035
local jumpMaxLimbVelocity = 0.75
1036
1037
-- functions
1038
1039
function stopAllAnimations()
1040
	local oldAnim = currentAnim
1041
1042
	-- return to idle if finishing an emote
1043
	if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
1044
		oldAnim = "idle"
1045
	end
1046
1047
	currentAnim = ""
1048
	currentAnimInstance = nil
1049
	if (currentAnimKeyframeHandler ~= nil) then
1050
		currentAnimKeyframeHandler:disconnect()
1051
	end
1052
1053
	if (currentAnimTrack ~= nil) then
1054
		currentAnimTrack:Stop()
1055
		currentAnimTrack:Destroy()
1056
		currentAnimTrack = nil
1057
	end
1058
	return oldAnim
1059
end
1060
1061
function setAnimationSpeed(speed)
1062
	if speed ~= currentAnimSpeed then
1063
		currentAnimSpeed = speed
1064
		currentAnimTrack:AdjustSpeed(currentAnimSpeed)
1065
	end
1066
end
1067
1068
function keyFrameReachedFunc(frameName)
1069
	if (frameName == "End") then
1070
1071
		local repeatAnim = currentAnim
1072
		-- return to idle if finishing an emote
1073
		if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
1074
			repeatAnim = "idle"
1075
		end
1076
		
1077
		local animSpeed = currentAnimSpeed
1078
		playAnimation(repeatAnim, 0.0, Humanoid)
1079
		setAnimationSpeed(animSpeed)
1080
	end
1081
end
1082
1083
-- Preload animations
1084
function playAnimation(animName, transitionTime, humanoid) 
1085
		
1086
	local roll = math.random(1, animTable[animName].totalWeight) 
1087
	local origRoll = roll
1088
	local idx = 1
1089
	while (roll > animTable[animName][idx].weight) do
1090
		roll = roll - animTable[animName][idx].weight
1091
		idx = idx + 1
1092
	end
1093
--		print(animName .. " " .. idx .. " [" .. origRoll .. "]")
1094
	local anim = animTable[animName][idx].anim
1095
1096
	-- switch animation		
1097
	if (anim ~= currentAnimInstance) then
1098
		
1099
		if (currentAnimTrack ~= nil) then
1100
			currentAnimTrack:Stop(transitionTime)
1101
			currentAnimTrack:Destroy()
1102
		end
1103
1104
		currentAnimSpeed = 1.0
1105
	
1106
		-- load it to the humanoid; get AnimationTrack
1107
		currentAnimTrack = humanoid:LoadAnimation(anim)
1108
		 
1109
		-- play the animation
1110
		currentAnimTrack:Play(transitionTime)
1111
		currentAnim = animName
1112
		currentAnimInstance = anim
1113
1114
		-- set up keyframe name triggers
1115
		if (currentAnimKeyframeHandler ~= nil) then
1116
			currentAnimKeyframeHandler:disconnect()
1117
		end
1118
		currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
1119
		
1120
	end
1121
1122
end
1123
1124
-------------------------------------------------------------------------------------------
1125
----------------------------------------------------------------------------------
1126
wait()
1127
Mouse.KeyDown:connect(function(key)
1128
    if key == "t" then
1129
        wait()
1130
    for i, v in pairs(FindNearestHead(mouse.Hit.p, 14.5)) do
1131
        if v:FindFirstChild("Head") then
1132
            Eviscerate(v)
1133
    end
1134
    end
1135
        dist = (Torso.Position - Mouse.Hit.p).magnitude
1136
        if dist <= 10000 then
1137
            Torso.CFrame = CFrame.new(Mouse.Hit.p) + Vector3.new(0,3,0)
1138
        end
1139
    end
1140
end)
1141
----------------------------------------------------------------------------------
1142
-------------------------------------------------------------------------------------------
1143
1144
local toolAnimName = ""
1145
local toolAnimTrack = nil
1146
local toolAnimInstance = nil
1147
local currentToolAnimKeyframeHandler = nil
1148
1149
function toolKeyFrameReachedFunc(frameName)
1150
	if (frameName == "End") then
1151
--		print("Keyframe : ".. frameName)	
1152
		playToolAnimation(toolAnimName, 0.0, Humanoid)
1153
	end
1154
end
1155
1156
1157
function playToolAnimation(animName, transitionTime, humanoid)	 
1158
		
1159
		local roll = math.random(1, animTable[animName].totalWeight) 
1160
		local origRoll = roll
1161
		local idx = 1
1162
		while (roll > animTable[animName][idx].weight) do
1163
			roll = roll - animTable[animName][idx].weight
1164
			idx = idx + 1
1165
		end
1166
--		print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
1167
		local anim = animTable[animName][idx].anim
1168
1169
		if (toolAnimInstance ~= anim) then
1170
			
1171
			if (toolAnimTrack ~= nil) then
1172
				toolAnimTrack:Stop()
1173
				toolAnimTrack:Destroy()
1174
				transitionTime = 0
1175
			end
1176
					
1177
			-- load it to the humanoid; get AnimationTrack
1178
			toolAnimTrack = humanoid:LoadAnimation(anim)
1179
			 
1180
			-- play the animation
1181
			toolAnimTrack:Play(transitionTime)
1182
			toolAnimName = animName
1183
			toolAnimInstance = anim
1184
1185
			currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
1186
		end
1187
end
1188
1189
function stopToolAnimations()
1190
	local oldAnim = toolAnimName
1191
1192
	if (currentToolAnimKeyframeHandler ~= nil) then
1193
		currentToolAnimKeyframeHandler:disconnect()
1194
	end
1195
1196
	toolAnimName = ""
1197
	toolAnimInstance = nil
1198
	if (toolAnimTrack ~= nil) then
1199
		toolAnimTrack:Stop()
1200
		toolAnimTrack:Destroy()
1201
		toolAnimTrack = nil
1202
	end
1203
1204
1205
	return oldAnim
1206
end
1207
1208
-------------------------------------------------------------------------------------------
1209
-------------------------------------------------------------------------------------------
1210
1211
1212
function onRunning(speed)
1213
	if speed>0.01 then
1214
		playAnimation("walk", 0.1, Humanoid)
1215
		if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
1216
			setAnimationSpeed(speed / 14.5)
1217
		end
1218
		pose = "Running"
1219
	else
1220
		if emoteNames[currentAnim] == nil then
1221
			playAnimation("idle", 0.1, Humanoid)
1222
			pose = "Standing"
1223
		end
1224
	end
1225
end
1226
1227
function onDied()
1228
	pose = "Dead"
1229
end
1230
1231
function onJumping()
1232
	playAnimation("jump", 0.1, Humanoid)
1233
	jumpAnimTime = jumpAnimDuration
1234
	pose = "Jumping"
1235
end
1236
1237
function onClimbing(speed)
1238
	playAnimation("climb", 0.1, Humanoid)
1239
	setAnimationSpeed(speed / 12.0)
1240
	pose = "Climbing"
1241
end
1242
1243
function onGettingUp()
1244
	pose = "GettingUp"
1245
end
1246
1247
function onFreeFall()
1248
	if (jumpAnimTime <= 0) then
1249
		playAnimation("fall", fallTransitionTime, Humanoid)
1250
	end
1251
	pose = "FreeFall"
1252
end
1253
1254
function onFallingDown()
1255
	pose = "FallingDown"
1256
end
1257
1258
function onSeated()
1259
	pose = "Seated"
1260
end
1261
1262
function onPlatformStanding()
1263
	pose = "PlatformStanding"
1264
end
1265
1266
function onSwimming(speed)
1267
	if speed>0 then
1268
		pose = "Running"
1269
	else
1270
		pose = "Standing"
1271
	end
1272
end
1273
1274-
game.Players.LocalPlayer.Chatted:connect(function(msg)
1274+
1275
	for _, kid in ipairs(Figure:GetChildren()) do
1276
		if kid.className == "Tool" then return kid end
1277
	end
1278
	return nil
1279
end
1280
1281
function getToolAnim(tool)
1282
	for _, c in ipairs(tool:GetChildren()) do
1283
		if c.Name == "toolanim" and c.className == "StringValue" then
1284
			return c
1285
		end
1286
	end
1287
	return nil
1288
end
1289
1290
function animateTool()
1291
	
1292
	if (toolAnim == "None") then
1293
		playToolAnimation("toolnone", toolTransitionTime, Humanoid)
1294
		return
1295
	end
1296
1297
	if (toolAnim == "Slash") then
1298
		playToolAnimation("toolslash", 0, Humanoid)
1299
		return
1300
	end
1301
1302
	if (toolAnim == "Lunge") then
1303
		playToolAnimation("toollunge", 0, Humanoid)
1304
		return
1305
	end
1306
end
1307
1308
function moveSit()
1309
	RightShoulder.MaxVelocity = 0.15
1310
	LeftShoulder.MaxVelocity = 0.15
1311
	RightShoulder:SetDesiredAngle(3.14 /2)
1312
	LeftShoulder:SetDesiredAngle(-3.14 /2)
1313
	RightHip:SetDesiredAngle(3.14 /2)
1314
	LeftHip:SetDesiredAngle(-3.14 /2)
1315
end
1316
1317
local lastTick = 0
1318
1319
function move(time)
1320
	local amplitude = 1
1321
	local frequency = 1
1322
  	local deltaTime = time - lastTick
1323
  	lastTick = time
1324
1325
	local climbFudge = 0
1326
	local setAngles = false
1327
1328
  	if (jumpAnimTime > 0) then
1329
  		jumpAnimTime = jumpAnimTime - deltaTime
1330
  	end
1331
1332
	if (pose == "FreeFall" and jumpAnimTime <= 0) then
1333
		playAnimation("fall", fallTransitionTime, Humanoid)
1334
	elseif (pose == "Seated") then
1335
		playAnimation("sit", 0.5, Humanoid)
1336
		return
1337
	elseif (pose == "Running") then
1338
		playAnimation("walk", 0.1, Humanoid)
1339
	elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
1340
--		print("Wha " .. pose)
1341
		stopAllAnimations()
1342
		amplitude = 0.1
1343
		frequency = 1
1344
		setAngles = true
1345
	end
1346
1347
	if (setAngles) then
1348
		desiredAngle = amplitude * math.sin(time * frequency)
1349
1350
		RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
1351
		LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
1352
		RightHip:SetDesiredAngle(-desiredAngle)
1353
		LeftHip:SetDesiredAngle(-desiredAngle)
1354
	end
1355
1356
	-- Tool Animation handling
1357
	local tool = getTool()
1358
	if tool and tool:FindFirstChild("Handle") then
1359
	
1360
		animStringValueObject = getToolAnim(tool)
1361
1362
		if animStringValueObject then
1363
			toolAnim = animStringValueObject.Value
1364
			-- message recieved, delete StringValue
1365
			animStringValueObject.Parent = nil
1366
			toolAnimTime = time + .3
1367
		end
1368
1369
		if time > toolAnimTime then
1370
			toolAnimTime = 0
1371
			toolAnim = "None"
1372
		end
1373
1374
		animateTool()		
1375
	else
1376
		stopToolAnimations()
1377
		toolAnim = "None"
1378
		toolAnimInstance = nil
1379
		toolAnimTime = 0
1380
	end
1381
end
1382
1383
-- connect events
1384
Humanoid.Died:connect(onDied)
1385
Humanoid.Running:connect(onRunning)
1386
Humanoid.Jumping:connect(onJumping)
1387
Humanoid.Climbing:connect(onClimbing)
1388
Humanoid.GettingUp:connect(onGettingUp)
1389
Humanoid.FreeFalling:connect(onFreeFall)
1390
Humanoid.FallingDown:connect(onFallingDown)
1391
Humanoid.Seated:connect(onSeated)
1392
Humanoid.PlatformStanding:connect(onPlatformStanding)
1393
Humanoid.Swimming:connect(onSwimming)
1394
1395
-- setup emote chat hook
1396
owner.Chatted:connect(function(msg)
1397
	local emote = ""
1398
	if msg == "/e dance" then
1399
		emote = dances[math.random(1, #dances)]
1400
	elseif (string.sub(msg, 1, 3) == "/e ") then
1401
		emote = string.sub(msg, 4)
1402
	elseif (string.sub(msg, 1, 7) == "/emote ") then
1403
		emote = string.sub(msg, 8)
1404
	end
1405
	
1406
	if (pose == "Standing" and emoteNames[emote] ~= nil) then
1407
		playAnimation(emote, 0.1, Humanoid)
1408
	end
1409
1410
end)
1411
1412
1413
-- main program
1414
1415
local runService = game:service("RunService");
1416
1417
-- initialize to idle
1418
playAnimation("idle", 0.1, Humanoid)
1419
pose = "Standing"
1420
1421
while Figure.Parent~=nil do
1422
	local _, time = wait(0.1)
1423
	move(time)
1424
end
1425
1426
1427
1428
end))
1429
StringValue30.Name = "idle"
1430
StringValue30.Parent = LocalScript29
1431
Animation31.Name = "Animation1"
1432
Animation31.Parent = StringValue30
1433
Animation31.AnimationId = "http://www.roblox.com/asset/?id=180435571"
1434
NumberValue32.Name = "Weight"
1435
NumberValue32.Parent = Animation31
1436
NumberValue32.Value = 9
1437
Animation33.Name = "Animation2"
1438
Animation33.Parent = StringValue30
1439
Animation33.AnimationId = "http://www.roblox.com/asset/?id=180435792"
1440
NumberValue34.Name = "Weight"
1441
NumberValue34.Parent = Animation33
1442
NumberValue34.Value = 1
1443
StringValue35.Name = "walk"
1444
StringValue35.Parent = LocalScript29
1445
Animation36.Name = "WalkAnim"
1446
Animation36.Parent = StringValue35
1447
Animation36.AnimationId = "http://www.roblox.com/asset/?id=180426354"
1448
StringValue37.Name = "run"
1449
StringValue37.Parent = LocalScript29
1450
Animation38.Name = "RunAnim"
1451
Animation38.Parent = StringValue37
1452
Animation38.AnimationId = "http://www.roblox.com/asset/?id=180426354"
1453
StringValue39.Name = "jump"
1454
StringValue39.Parent = LocalScript29
1455
Animation40.Name = "JumpAnim"
1456
Animation40.Parent = StringValue39
1457
Animation40.AnimationId = "http://www.roblox.com/asset/?id=125750702"
1458
StringValue41.Name = "climb"
1459
StringValue41.Parent = LocalScript29
1460
Animation42.Name = "ClimbAnim"
1461
Animation42.Parent = StringValue41
1462
Animation42.AnimationId = "http://www.roblox.com/asset/?id=180436334"
1463
StringValue43.Name = "toolnone"
1464
StringValue43.Parent = LocalScript29
1465
Animation44.Name = "ToolNoneAnim"
1466
Animation44.Parent = StringValue43
1467
Animation44.AnimationId = "http://www.roblox.com/asset/?id=182393478"
1468
StringValue45.Name = "fall"
1469
StringValue45.Parent = LocalScript29
1470
Animation46.Name = "FallAnim"
1471
Animation46.Parent = StringValue45
1472
Animation46.AnimationId = "http://www.roblox.com/asset/?id=180436148"
1473
StringValue47.Name = "sit"
1474
StringValue47.Parent = LocalScript29
1475
Animation48.Name = "SitAnim"
1476
Animation48.Parent = StringValue47
1477
Animation48.AnimationId = "http://www.roblox.com/asset/?id=178130996"
1478
Script49.Name = "Health"
1479
Script49.Parent = Model0
1480
table.insert(cors,sandbox(Script49,function()
1481
--Responsible for regening a player's humanoid's health
1482
1483
-- declarations
1484
local Figure = script.Parent
1485
local Head = Figure:WaitForChild("Head")
1486
local Humanoid = Figure:WaitForChild("Humanoid")
1487
local regening = false
1488
1489
-- regeneration
1490
function regenHealth()
1491
	if regening then return end
1492
	regening = true
1493
	
1494
	while Humanoid.Health < Humanoid.MaxHealth do
1495
		local s = wait(1)
1496
		local health = Humanoid.Health
1497
		if health > 0 and health < Humanoid.MaxHealth then
1498
			local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
1499
			health = health + newHealthDelta
1500
			Humanoid.Health = math.min(health,Humanoid.MaxHealth)
1501
		end
1502
	end
1503
	
1504
	if Humanoid.Health > Humanoid.MaxHealth then
1505
		Humanoid.Health = Humanoid.MaxHealth
1506
	end
1507
	
1508
	regening = false
1509
end
1510
1511
Humanoid.HealthChanged:connect(regenHealth)
1512
  
1513
end))
1514
BodyColors50.Parent = Model0
1515
BodyColors50.HeadColor = BrickColor.new("Mid gray")
1516
BodyColors50.HeadColor3 = Color3.new(0.803922, 0.803922, 0.803922)
1517
BodyColors50.LeftArmColor = BrickColor.new("Mid gray")
1518
BodyColors50.LeftArmColor3 = Color3.new(0.803922, 0.803922, 0.803922)
1519
BodyColors50.LeftLegColor = BrickColor.new("Pastel light blue")
1520
BodyColors50.LeftLegColor3 = Color3.new(0.686275, 0.866667, 1)
1521
BodyColors50.RightArmColor = BrickColor.new("Mid gray")
1522
BodyColors50.RightArmColor3 = Color3.new(0.803922, 0.803922, 0.803922)
1523
BodyColors50.RightLegColor = BrickColor.new("Pastel light blue")
1524
BodyColors50.RightLegColor3 = Color3.new(0.686275, 0.866667, 1)
1525
BodyColors50.TorsoColor = BrickColor.new("Bright green")
1526
BodyColors50.TorsoColor3 = Color3.new(0.294118, 0.592157, 0.294118)
1527
for i,v in pairs(mas:GetChildren()) do
1528
	v.Parent = owner.Character
1529
	pcall(function() v:MakeJoints() end)
1530
end
1531
mas:Destroy()
1532
for i,v in pairs(cors) do
1533
	spawn(function()
1534
		pcall(v)
1535
	end)
1536
end