View difference between Paste ID: bsytyLnJ and U5SahFsB
SHOW: | | - or go back to the newest paste.
1-
://www.roblox.com/library/105738562/Mad-Father-Alfred-Drevis--Converted with ttyyuu12345's model to script plugin v4
1+
--Converted with ttyyuu12345's model to script plugin v4
2
function sandbox(var,funhttpsc)
3
	local env = getfenv(func)
4
	local newenv = setmetatable({},{
5
		__index = function(self,k)
6
			if k=="script" then
7
				return var
8
			else
9
				return env[k]
10
			end
11
		end,
12
	})
13
	setfenv(func,newenv)
14
	return func
15
end
16
cors = {}
17
mas = Instance.new("Model",game:GetService("Lighting"))
18
Model0 = Instance.new("Model")
19
Part1 = Instance.new("Part")
20
Sound2 = Instance.new("Sound")
21
Sound3 = Instance.new("Sound")
22
Sound4 = Instance.new("Sound")
23
Decal5 = Instance.new("Decal")
24
SpecialMesh6 = Instance.new("SpecialMesh")
25
Weld7 = Instance.new("Weld")
26
Part8 = Instance.new("Part")
27
Decal9 = Instance.new("Decal")
28
Motor6D10 = Instance.new("Motor6D")
29
Motor6D11 = Instance.new("Motor6D")
30
Motor6D12 = Instance.new("Motor6D")
31
Motor6D13 = Instance.new("Motor6D")
32
Motor6D14 = Instance.new("Motor6D")
33
Part15 = Instance.new("Part")
34
Part16 = Instance.new("Part")
35
Part17 = Instance.new("Part")
36
Part18 = Instance.new("Part")
37
Humanoid19 = Instance.new("Humanoid")
38
Part20 = Instance.new("Part")
39
Motor6D21 = Instance.new("Motor6D")
40
Script22 = Instance.new("Script")
41
BodyColors23 = Instance.new("BodyColors")
42
Script24 = Instance.new("Script")
43
StringValue25 = Instance.new("StringValue")
44
Animation26 = Instance.new("Animation")
45
StringValue27 = Instance.new("StringValue")
46
Animation28 = Instance.new("Animation")
47
StringValue29 = Instance.new("StringValue")
48
Animation30 = Instance.new("Animation")
49
NumberValue31 = Instance.new("NumberValue")
50
Animation32 = Instance.new("Animation")
51
NumberValue33 = Instance.new("NumberValue")
52
StringValue34 = Instance.new("StringValue")
53
Animation35 = Instance.new("Animation")
54
StringValue36 = Instance.new("StringValue")
55
Animation37 = Instance.new("Animation")
56
StringValue38 = Instance.new("StringValue")
57
Animation39 = Instance.new("Animation")
58
StringValue40 = Instance.new("StringValue")
59
Animation41 = Instance.new("Animation")
60
StringValue42 = Instance.new("StringValue")
61
Animation43 = Instance.new("Animation")
62
Sound44 = Instance.new("Sound")
63
Script45 = Instance.new("Script")
64
Animation46 = Instance.new("Animation")
65
CharacterMesh47 = Instance.new("CharacterMesh")
66
CharacterMesh48 = Instance.new("CharacterMesh")
67
CharacterMesh49 = Instance.new("CharacterMesh")
68
CharacterMesh50 = Instance.new("CharacterMesh")
69
CharacterMesh51 = Instance.new("CharacterMesh")
70
Shirt52 = Instance.new("Shirt")
71
Pants53 = Instance.new("Pants")
72
Hat54 = Instance.new("Hat")
73
Part55 = Instance.new("Part")
74
SpecialMesh56 = Instance.new("SpecialMesh")
75
Script57 = Instance.new("Script")
76
Animation58 = Instance.new("Animation")
77
BindableFunction59 = Instance.new("BindableFunction")
78
BindableEvent60 = Instance.new("BindableEvent")
79
BindableEvent61 = Instance.new("BindableEvent")
80
BindableEvent62 = Instance.new("BindableEvent")
81
Configuration63 = Instance.new("Configuration")
82
ObjectValue64 = Instance.new("ObjectValue")
83
Configuration65 = Instance.new("Configuration")
84
NumberValue66 = Instance.new("NumberValue")
85
BoolValue67 = Instance.new("BoolValue")
86
BoolValue68 = Instance.new("BoolValue")
87
Vector3Value69 = Instance.new("Vector3Value")
88
BoolValue70 = Instance.new("BoolValue")
89
BrickColorValue71 = Instance.new("BrickColorValue")
90
NumberValue72 = Instance.new("NumberValue")
91
NumberValue73 = Instance.new("NumberValue")
92
NumberValue74 = Instance.new("NumberValue")
93
Model0.Name = "DrTrayBlox"
94
Model0.Parent = mas
95
Part1.Name = "Head"
96
Part1.Parent = Model0
97
Part1.BrickColor = BrickColor.new("Pastel brown")
98
Part1.Rotation = Vector3.new(0, -57.8199997, 0)
99
Part1.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
100
Part1.Locked = true
101
Part1.FormFactor = Enum.FormFactor.Symmetric
102
Part1.Size = Vector3.new(2, 1, 1)
103
Part1.CFrame = CFrame.new(20.9954529, 4.50000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
104
Part1.TopSurface = Enum.SurfaceType.Smooth
105
Part1.Color = Color3.new(1, 0.8, 0.6)
106
Part1.Position = Vector3.new(20.9954529, 4.50000906, 7.42480421)
107
Part1.Orientation = Vector3.new(0, -57.8199997, 0)
108
Part1.Color = Color3.new(1, 0.8, 0.6)
109
Sound2.Name = "StomedyHit"
110
Sound2.Parent = Part1
111
Sound2.Pitch = 1.5
112
Sound2.SoundId = "rbxassetid://386946017"
113
Sound2.Volume = 1
114
Sound3.Name = "StomedyMain"
115
Sound3.Parent = Part1
116
Sound3.Volume = 1
117
Sound3.Looped = true
118
Sound4.Name = "StomedyStep"
119
Sound4.Parent = Part1
120
Sound4.Pitch = 2.0999999046326
121
Sound4.SoundId = "rbxassetid://379611235"
122
Sound4.Volume = 1
123
Decal5.Name = "face"
124
Decal5.Parent = Part1
125
Decal5.Texture = "rbxasset://textures/face.png"
126
SpecialMesh6.Parent = Part1
127
SpecialMesh6.MeshId = "http://www.roblox.com/asset/?id=83001675"
128
SpecialMesh6.Scale = Vector3.new(1.25, 1.25, 1.25)
129
SpecialMesh6.MeshType = Enum.MeshType.FileMesh
130
SpecialMesh6.Scale = Vector3.new(1.25, 1.25, 1.25)
131
Weld7.Name = "HeadWeld"
132
Weld7.Parent = Part1
133
Weld7.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
134
Weld7.C1 = CFrame.new(0, 0.200000003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
135
Weld7.Part0 = Part1
136
Weld7.Part1 = Part55
137
Part8.Name = "Torso"
138
Part8.Parent = Model0
139
Part8.BrickColor = BrickColor.new("White")
140
Part8.Rotation = Vector3.new(0, -57.8199997, 0)
141
Part8.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
142
Part8.Locked = true
143
Part8.FormFactor = Enum.FormFactor.Symmetric
144
Part8.Size = Vector3.new(2, 2, 1)
145
Part8.CFrame = CFrame.new(20.9954529, 3.00000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
146
Part8.LeftSurface = Enum.SurfaceType.Weld
147
Part8.RightSurface = Enum.SurfaceType.Weld
148
Part8.Color = Color3.new(0.94902, 0.952941, 0.952941)
149
Part8.Position = Vector3.new(20.9954529, 3.00000906, 7.42480421)
150
Part8.Orientation = Vector3.new(0, -57.8199997, 0)
151
Part8.Color = Color3.new(0.94902, 0.952941, 0.952941)
152
Decal9.Name = "roblox"
153
Decal9.Parent = Part8
154
Motor6D10.Name = "Right Shoulder"
155
Motor6D10.Parent = Part8
156
Motor6D10.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
157
Motor6D10.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
158
Motor6D10.Part0 = Part8
159
Motor6D10.Part1 = Part16
160
Motor6D10.MaxVelocity = 0.10000000149012
161
Motor6D11.Name = "Left Shoulder"
162
Motor6D11.Parent = Part8
163
Motor6D11.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
164
Motor6D11.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
165
Motor6D11.Part0 = Part8
166
Motor6D11.Part1 = Part15
167
Motor6D11.MaxVelocity = 0.10000000149012
168
Motor6D12.Name = "Right Hip"
169
Motor6D12.Parent = Part8
170
Motor6D12.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
171
Motor6D12.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
172
Motor6D12.Part0 = Part8
173
Motor6D12.Part1 = Part18
174
Motor6D12.MaxVelocity = 0.10000000149012
175
Motor6D13.Name = "Left Hip"
176
Motor6D13.Parent = Part8
177
Motor6D13.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
178
Motor6D13.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
179
Motor6D13.Part0 = Part8
180
Motor6D13.Part1 = Part17
181
Motor6D13.MaxVelocity = 0.10000000149012
182
Motor6D14.Name = "Neck"
183
Motor6D14.Parent = Part8
184
Motor6D14.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
185
Motor6D14.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
186
Motor6D14.Part0 = Part8
187
Motor6D14.Part1 = Part1
188
Motor6D14.MaxVelocity = 0.10000000149012
189
Part15.Name = "Left Arm"
190
Part15.Parent = Model0
191
Part15.BrickColor = BrickColor.new("Pastel brown")
192
Part15.Rotation = Vector3.new(0, -57.8199997, 0)
193
Part15.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
194
Part15.CanCollide = false
195
Part15.Locked = true
196
Part15.FormFactor = Enum.FormFactor.Symmetric
197
Part15.Size = Vector3.new(1, 2, 1)
198
Part15.CFrame = CFrame.new(20.1965046, 3.00000906, 6.1552844, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
199
Part15.Color = Color3.new(1, 0.8, 0.6)
200
Part15.Position = Vector3.new(20.1965046, 3.00000906, 6.1552844)
201
Part15.Orientation = Vector3.new(0, -57.8199997, 0)
202
Part15.Color = Color3.new(1, 0.8, 0.6)
203
Part16.Name = "Right Arm"
204
Part16.Parent = Model0
205
Part16.BrickColor = BrickColor.new("Pastel brown")
206
Part16.Rotation = Vector3.new(0, -57.8199997, 0)
207
Part16.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
208
Part16.CanCollide = false
209
Part16.Locked = true
210
Part16.FormFactor = Enum.FormFactor.Symmetric
211
Part16.Size = Vector3.new(1, 2, 1)
212
Part16.CFrame = CFrame.new(21.7944012, 3.00000906, 8.69432449, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
213
Part16.Color = Color3.new(1, 0.8, 0.6)
214
Part16.Position = Vector3.new(21.7944012, 3.00000906, 8.69432449)
215
Part16.Orientation = Vector3.new(0, -57.8199997, 0)
216
Part16.Color = Color3.new(1, 0.8, 0.6)
217
Part17.Name = "Left Leg"
218
Part17.Parent = Model0
219
Part17.BrickColor = BrickColor.new("Medium blue")
220
Part17.Rotation = Vector3.new(0, -57.8199997, 0)
221
Part17.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
222
Part17.CanCollide = false
223
Part17.Locked = true
224
Part17.FormFactor = Enum.FormFactor.Symmetric
225
Part17.Size = Vector3.new(1, 2, 1)
226
Part17.CFrame = CFrame.new(20.7291374, 1.00000906, 7.00163078, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
227
Part17.BottomSurface = Enum.SurfaceType.Smooth
228
Part17.Color = Color3.new(0.431373, 0.6, 0.792157)
229
Part17.Position = Vector3.new(20.7291374, 1.00000906, 7.00163078)
230
Part17.Orientation = Vector3.new(0, -57.8199997, 0)
231
Part17.Color = Color3.new(0.431373, 0.6, 0.792157)
232
Part18.Name = "Right Leg"
233
Part18.Parent = Model0
234
Part18.BrickColor = BrickColor.new("Medium blue")
235
Part18.Rotation = Vector3.new(0, -57.8199997, 0)
236
Part18.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
237
Part18.CanCollide = false
238
Part18.Locked = true
239
Part18.FormFactor = Enum.FormFactor.Symmetric
240
Part18.Size = Vector3.new(1, 2, 1)
241
Part18.CFrame = CFrame.new(21.2617683, 1.00000906, 7.84797764, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
242
Part18.BottomSurface = Enum.SurfaceType.Smooth
243
Part18.Color = Color3.new(0.431373, 0.6, 0.792157)
244
Part18.Position = Vector3.new(21.2617683, 1.00000906, 7.84797764)
245
Part18.Orientation = Vector3.new(0, -57.8199997, 0)
246
Part18.Color = Color3.new(0.431373, 0.6, 0.792157)
247
Humanoid19.Parent = Model0
248
Humanoid19.RightLeg = Part18
249
Humanoid19.LeftLeg = Part17
250
Humanoid19.Torso = Part20
251
Part20.Name = "HumanoidRootPart"
252
Part20.Parent = Model0
253
Part20.Transparency = 1
254
Part20.Rotation = Vector3.new(0, -57.8199997, 0)
255
Part20.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
256
Part20.CanCollide = false
257
Part20.Locked = true
258
Part20.FormFactor = Enum.FormFactor.Symmetric
259
Part20.Size = Vector3.new(2, 2, 1)
260
Part20.CFrame = CFrame.new(20.9954529, 3.00000906, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
261
Part20.BottomSurface = Enum.SurfaceType.Smooth
262
Part20.TopSurface = Enum.SurfaceType.Smooth
263
Part20.Position = Vector3.new(20.9954529, 3.00000906, 7.42480421)
264
Part20.Orientation = Vector3.new(0, -57.8199997, 0)
265
Motor6D21.Name = "RootJoint"
266
Motor6D21.Parent = Part20
267
Motor6D21.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
268
Motor6D21.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
269
Motor6D21.Part0 = Part20
270
Motor6D21.Part1 = Part8
271
Motor6D21.MaxVelocity = 0.10000000149012
272
Script22.Name = "Health"
273
Script22.Parent = Model0
274
table.insert(cors,sandbox(Script22,function()
275
--Responsible for regening a player's humanoid's health
276
277
-- declarations
278
local Figure = script.Parent
279
local Head = Figure:WaitForChild("Head")
280
local Humanoid = Figure:WaitForChild("Humanoid")
281
local regening = false
282
283
-- regeneration
284
function regenHealth()
285
	if regening then return end
286
	regening = true
287
	
288
	while Humanoid.Health < Humanoid.MaxHealth do
289
		local s = wait(1)
290
		local health = Humanoid.Health
291
		if health > 0 and health < Humanoid.MaxHealth then
292
			local newHealthDelta = 250 * s * Humanoid.MaxHealth
293
			health = health + newHealthDelta
294
			Humanoid.Health = math.min(health,Humanoid.MaxHealth)
295
		end
296
	end
297
	
298
	if Humanoid.Health > Humanoid.MaxHealth then
299
		Humanoid.Health = Humanoid.MaxHealth
300
	end
301
	
302
	regening = false
303
end
304
305
Humanoid.HealthChanged:connect(regenHealth)
306
  
307
end))
308
BodyColors23.Parent = Model0
309
BodyColors23.HeadColor = BrickColor.new("Pastel brown")
310
BodyColors23.LeftArmColor = BrickColor.new("Pastel brown")
311
BodyColors23.LeftLegColor = BrickColor.new("Medium blue")
312
BodyColors23.RightArmColor = BrickColor.new("Pastel brown")
313
BodyColors23.RightLegColor = BrickColor.new("Medium blue")
314
BodyColors23.TorsoColor = BrickColor.new("White")
315
Script24.Name = "AnimateSauce"
316
Script24.Parent = Model0
317
table.insert(cors,sandbox(Script24,function()
318
function   waitForChild(parent, childName)
319
local child = parent:findFirstChild(childName)
320
if child then return child end
321
while true do
322
child = parent.ChildAdded:wait()
323
if child.Name==childName then return child end
324
end
325
end
326
local Figure = script.Parent
327
local Torso = waitForChild(Figure, "Torso")
328
local RightShoulder = waitForChild(Torso, "Right Shoulder")
329
local LeftShoulder = waitForChild(Torso, "Left Shoulder")
330
local RightHip = waitForChild(Torso, "Right Hip")
331
local LeftHip = waitForChild(Torso, "Left Hip")
332
local Neck = waitForChild(Torso, "Neck")
333
local Humanoid;
334
for _,Child in pairs(Figure:GetChildren())do
335
if Child and Child.ClassName=="Humanoid"then
336
Humanoid=Child;
337
end;
338
end;
339
local pose = "Standing"
340
local currentAnim = ""
341
local currentAnimInstance = nil
342
local currentAnimTrack = nil
343
local currentAnimKeyframeHandler = nil
344
local currentAnimSpeed = 1.0
345
local animTable = {}
346
local animNames = { 
347
idle = {
348
{ id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
349
{ id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
350
},
351
walk = { 
352
{ id = "http://www.roblox.com/asset/?id=180426354", weight = 10 } 
353
}, 
354
run = {
355
{ id = "http://www.roblox.com/asset/?id=252557606", weight = 20 } 
356
}, 
357
jump = {
358
{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 } 
359
}, 
360
fall = {
361
{ id = "http://www.roblox.com/asset/?id=180436148", weight = 10 } 
362
}, 
363
climb = {
364
{ id = "http://www.roblox.com/asset/?id=180436334", weight = 10 } 
365
}, 
366
sit = {
367
{ id = "http://www.roblox.com/asset/?id=178130996", weight = 10 } 
368
},
369
toolnone = {
370
{ id = "http://www.roblox.com/asset/?id=182393478", weight = 10 } 
371
},
372
toolslash = {
373
{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 } 
374
--{ id = "slash.xml", weight = 10 } 
375
},
376
toollunge = {
377
{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 } 
378
},
379
wave = {
380
{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 } 
381
},
382
point = {
383
{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 } 
384
},
385
dance1 = {
386
{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 }, 
387
{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 }, 
388
{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 } 
389
},
390
dance2 = {
391
{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 }, 
392
{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 }, 
393
{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 } 
394
},
395
dance3 = {
396
{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 }, 
397
{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 }, 
398
{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 } 
399
},
400
laugh = {
401
{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 } 
402
},
403
cheer = {
404
{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 } 
405
},
406
}
407
local dances = {"dance1", "dance2", "dance3"}
408
409
-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
410
local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
411
412
function configureAnimationSet(name, fileList)
413
if (animTable[name] ~= nil) then
414
for _, connection in pairs(animTable[name].connections) do
415
connection:disconnect()
416
end
417
end
418
animTable[name] = {}
419
animTable[name].count = 0
420
animTable[name].totalWeight = 0
421
animTable[name].connections = {}
422
423
-- check for config values
424
local config = script:FindFirstChild(name)
425
if (config ~= nil) then
426
--print("Loading anims " .. name)
427
table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
428
table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
429
local idx = 1
430
for _, childPart in pairs(config:GetChildren()) do
431
if (childPart:IsA("Animation")) then
432
table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
433
animTable[name][idx] = {}
434
animTable[name][idx].anim = childPart
435
local weightObject = childPart:FindFirstChild("Weight")
436
if (weightObject == nil) then
437
animTable[name][idx].weight = 1
438
else
439
animTable[name][idx].weight = weightObject.Value
440
end
441
animTable[name].count = animTable[name].count + 1
442
animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
443
--print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
444
idx = idx + 1
445
end
446
end
447
end
448
449
-- fallback to defaults
450
if (animTable[name].count <= 0) then
451
for idx, anim in pairs(fileList) do
452
animTable[name][idx] = {}
453
animTable[name][idx].anim = Instance.new("Animation")
454
animTable[name][idx].anim.Name = name
455
animTable[name][idx].anim.AnimationId = anim.id
456
animTable[name][idx].weight = anim.weight
457
animTable[name].count = animTable[name].count + 1
458
animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
459
--print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
460
end
461
end
462
end
463
464
-- Setup animation objects
465
function scriptChildModified(child)
466
local fileList = animNames[child.Name]
467
if (fileList ~= nil) then
468
configureAnimationSet(child.Name, fileList)
469
end
470
end
471
472
script.ChildAdded:connect(scriptChildModified)
473
script.ChildRemoved:connect(scriptChildModified)
474
475
476
for name, fileList in pairs(animNames) do 
477
configureAnimationSet(name, fileList)
478
end
479
480
-- ANIMATION
481
482
-- declarations
483
local toolAnim = "None"
484
local toolAnimTime = 0
485
486
local jumpAnimTime = 0
487
local jumpAnimDuration = 0.3
488
489
local toolTransitionTime = 0.1
490
local fallTransitionTime = 0.3
491
local jumpMaxLimbVelocity = 0.75
492
493
-- functions
494
495
function stopAllAnimations()
496
local oldAnim = currentAnim
497
498
-- return to idle if finishing an emote
499
if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
500
oldAnim = "idle"
501
end
502
503
currentAnim = ""
504
currentAnimInstance = nil
505
if (currentAnimKeyframeHandler ~= nil) then
506
currentAnimKeyframeHandler:disconnect()
507
end
508
509
if (currentAnimTrack ~= nil) then
510
currentAnimTrack:Stop()
511
currentAnimTrack:Destroy()
512
currentAnimTrack = nil
513
end
514
return oldAnim
515
end
516
517
function setAnimationSpeed(speed)
518
if speed ~= currentAnimSpeed then
519
currentAnimSpeed = speed
520
currentAnimTrack:AdjustSpeed(currentAnimSpeed)
521
end
522
end
523
524
function keyFrameReachedFunc(frameName)
525
if (frameName == "End") then
526
527
local repeatAnim = currentAnim
528
-- return to idle if finishing an emote
529
if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
530
repeatAnim = "idle"
531
end
532
533
local animSpeed = currentAnimSpeed
534
playAnimation(repeatAnim, 0.0, Humanoid)
535
setAnimationSpeed(animSpeed)
536
end
537
end
538
539
-- Preload animations
540
function playAnimation(animName, transitionTime, humanoid) 
541
542
local roll = math.random(1, animTable[animName].totalWeight) 
543
local origRoll = roll
544
local idx = 1
545
while (roll > animTable[animName][idx].weight) do
546
roll = roll - animTable[animName][idx].weight
547
idx = idx + 1
548
end
549
--print(animName .. " " .. idx .. " [" .. origRoll .. "]")
550
local anim = animTable[animName][idx].anim
551
-- switch animation
552
if (anim ~= currentAnimInstance) then
553
if (currentAnimTrack ~= nil) then
554
currentAnimTrack:Stop(transitionTime)
555
currentAnimTrack:Destroy()
556
end
557
currentAnimSpeed = 1.0
558
-- load it to the humanoid; get AnimationTrack
559
currentAnimTrack = humanoid:LoadAnimation(anim)
560
-- play the animation
561
currentAnimTrack:Play(transitionTime)
562
currentAnim = animName
563
currentAnimInstance = anim
564
-- set up keyframe name triggers
565
if (currentAnimKeyframeHandler ~= nil) then
566
currentAnimKeyframeHandler:disconnect()
567
end
568
currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
569
end
570
end
571
-------------------------------------------------------------------------------------------
572
-------------------------------------------------------------------------------------------
573
local toolAnimName = ""
574
local toolAnimTrack = nil
575
local toolAnimInstance = nil
576
local currentToolAnimKeyframeHandler = nil
577
function toolKeyFrameReachedFunc(frameName)
578
if (frameName == "End") then
579
--print("Keyframe : ".. frameName)
580
playToolAnimation(toolAnimName, 0.0, Humanoid)
581
end
582
end
583
function playToolAnimation(animName, transitionTime, humanoid) 
584
local roll = math.random(1, animTable[animName].totalWeight) 
585
local origRoll = roll
586
local idx = 1
587
while (roll > animTable[animName][idx].weight) do
588
roll = roll - animTable[animName][idx].weight
589
idx = idx + 1
590
end
591
--print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
592
local anim = animTable[animName][idx].anim
593
if (toolAnimInstance ~= anim) then
594
if (toolAnimTrack ~= nil) then
595
toolAnimTrack:Stop()
596
toolAnimTrack:Destroy()
597
transitionTime = 0
598
end
599
-- load it to the humanoid; get AnimationTrack
600
toolAnimTrack = humanoid:LoadAnimation(anim)
601
-- play the animation
602
toolAnimTrack:Play(transitionTime)
603
toolAnimName = animName
604
toolAnimInstance = anim
605
currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
606
end
607
end
608
function stopToolAnimations()
609
local oldAnim = toolAnimName
610
if (currentToolAnimKeyframeHandler ~= nil) then
611
currentToolAnimKeyframeHandler:disconnect()
612
end
613
toolAnimName = ""
614
toolAnimInstance = nil
615
if (toolAnimTrack ~= nil) then
616
toolAnimTrack:Stop()
617
toolAnimTrack:Destroy()
618
toolAnimTrack = nil
619
end
620
return oldAnim
621
end
622
-------------------------------------------------------------------------------------------
623
-------------------------------------------------------------------------------------------
624
function onRunning(speed)
625
if speed>0.01 then
626
if Figure and Humanoid and Humanoid.WalkSpeed<17 then
627
playAnimation("walk", 0.1, Humanoid);
628
elseif Figure and Humanoid and Humanoid.WalkSpeed>17 then
629
playAnimation("run", 0.1, Humanoid);
630
end;
631
if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
632
setAnimationSpeed(speed / 14.5)
633
end
634
pose = "Running"
635
else
636
playAnimation("idle", 0.1, Humanoid)
637
pose = "Standing"
638
end
639
end
640
function onDied()
641
pose = "Dead"
642
end
643
function onJumping()
644
playAnimation("jump", 0.1, Humanoid)
645
jumpAnimTime = jumpAnimDuration
646
pose = "Jumping"
647
end
648
function onClimbing(speed)
649
playAnimation("climb", 0.1, Humanoid)
650
setAnimationSpeed(speed / 12.0)
651
pose = "Climbing"
652
end
653
function onGettingUp()
654
pose = "GettingUp"
655
end
656
function onFreeFall()
657
if (jumpAnimTime <= 0) then
658
playAnimation("fall", fallTransitionTime, Humanoid)
659
end
660
pose = "FreeFall"
661
end
662
function onFallingDown()
663
pose = "FallingDown"
664
end
665
function onSeated()
666
pose = "Seated"
667
end
668
function onPlatformStanding()
669
pose = "PlatformStanding"
670
end
671
function onSwimming(speed)
672
if speed>0 then
673
pose = "Running"
674
else
675
pose = "Standing"
676
end
677
end
678
679
function getTool()
680
for _, kid in ipairs(Figure:GetChildren()) do
681
if kid.className == "Tool" then return kid end
682
end
683
return nil
684
end
685
686
function getToolAnim(tool)
687
for _, c in ipairs(tool:GetChildren()) do
688
if c.Name == "toolanim" and c.className == "StringValue" then
689
return c
690
end
691
end
692
return nil
693
end
694
695
function animateTool()
696
697
if (toolAnim == "None") then
698
playToolAnimation("toolnone", toolTransitionTime, Humanoid)
699
return
700
end
701
702
if (toolAnim == "Slash") then
703
playToolAnimation("toolslash", 0, Humanoid)
704
return
705
end
706
707
if (toolAnim == "Lunge") then
708
playToolAnimation("toollunge", 0, Humanoid)
709
return
710
end
711
end
712
713
function moveSit()
714
RightShoulder.MaxVelocity = 0.15
715
LeftShoulder.MaxVelocity = 0.15
716
RightShoulder:SetDesiredAngle(3.14 /2)
717
LeftShoulder:SetDesiredAngle(-3.14 /2)
718
RightHip:SetDesiredAngle(3.14 /2)
719
LeftHip:SetDesiredAngle(-3.14 /2)
720
end
721
722
local lastTick = 0
723
724
function move(time)
725
local amplitude = 1
726
local frequency = 1
727
  local deltaTime = time - lastTick
728
  lastTick = time
729
730
local climbFudge = 0
731
local setAngles = false
732
733
  if (jumpAnimTime > 0) then
734
  jumpAnimTime = jumpAnimTime - deltaTime
735
  end
736
737
if (pose == "FreeFall" and jumpAnimTime <= 0) then
738
playAnimation("fall", fallTransitionTime, Humanoid)
739
elseif (pose == "Seated") then
740
playAnimation("sit", 0.5, Humanoid)
741
return
742
elseif (pose == "Running") then
743
if Figure and Humanoid and Humanoid.WalkSpeed<17 then
744
playAnimation("walk", 0.1, Humanoid);
745
elseif Figure and Humanoid and Humanoid.WalkSpeed>17 then
746
playAnimation("run", 0.1, Humanoid);
747
end;
748
elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
749
stopAllAnimations()
750
amplitude = 0.1
751
frequency = 1
752
setAngles = true
753
end
754
if (setAngles) then
755
local desiredAngle = amplitude * math.sin(time * frequency)
756
RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
757
LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
758
RightHip:SetDesiredAngle(-desiredAngle)
759
LeftHip:SetDesiredAngle(-desiredAngle)
760
end
761
-- Tool Animation handling
762
local tool = getTool()
763
if tool and tool:FindFirstChild("Handle") then
764
local animStringValueObject = getToolAnim(tool)
765
if animStringValueObject then
766
toolAnim = animStringValueObject.Value
767
-- message recieved, delete StringValue
768
animStringValueObject.Parent = nil
769
toolAnimTime = time + .3
770
end
771
if time > toolAnimTime then
772
toolAnimTime = 0
773
toolAnim = "None"
774
end
775
animateTool()
776
else
777
stopToolAnimations()
778
toolAnim = "None"
779
toolAnimInstance = nil
780
toolAnimTime = 0
781
end
782
end
783
-- connect events
784
Humanoid.Died:connect(onDied)
785
Humanoid.Running:connect(onRunning)
786
Humanoid.Jumping:connect(onJumping)
787
Humanoid.Climbing:connect(onClimbing)
788
Humanoid.GettingUp:connect(onGettingUp)
789
Humanoid.FreeFalling:connect(onFreeFall)
790
Humanoid.FallingDown:connect(onFallingDown)
791
Humanoid.Seated:connect(onSeated)
792
Humanoid.PlatformStanding:connect(onPlatformStanding)
793
Humanoid.Swimming:connect(onSwimming)
794
local runService = game:GetService("RunService");
795
playAnimation("idle", 0.1, Humanoid)
796
pose = "Standing"
797
while Wait(0)do
798
local _,time=wait(0)
799
move(time)
800
end
801
end))
802
StringValue25.Name = "climb"
803
StringValue25.Parent = Script24
804
Animation26.Name = "ClimbAnim"
805
Animation26.Parent = StringValue25
806
Animation26.AnimationId = "http://www.roblox.com/asset/?id=180436334"
807
StringValue27.Name = "fall"
808
StringValue27.Parent = Script24
809
Animation28.Name = "FallAnim"
810
Animation28.Parent = StringValue27
811
Animation28.AnimationId = "http://www.roblox.com/asset/?id=180436148"
812
StringValue29.Name = "idle"
813
StringValue29.Parent = Script24
814
Animation30.Name = "Animation1"
815
Animation30.Parent = StringValue29
816
Animation30.AnimationId = "http://www.roblox.com/asset/?id=180435571"
817
NumberValue31.Name = "Weight"
818
NumberValue31.Parent = Animation30
819
NumberValue31.Value = 9
820
Animation32.Name = "Animation2"
821
Animation32.Parent = StringValue29
822
Animation32.AnimationId = "http://www.roblox.com/asset/?id=180435792"
823
NumberValue33.Name = "Weight"
824
NumberValue33.Parent = Animation32
825
NumberValue33.Value = 1
826
StringValue34.Name = "jump"
827
StringValue34.Parent = Script24
828
Animation35.Name = "JumpAnim"
829
Animation35.Parent = StringValue34
830
Animation35.AnimationId = "http://www.roblox.com/asset/?id=125750702"
831
StringValue36.Name = "run"
832
StringValue36.Parent = Script24
833
Animation37.Name = "RunAnim"
834
Animation37.Parent = StringValue36
835
Animation37.AnimationId = "http://www.roblox.com/asset/?id=252557606"
836
StringValue38.Name = "sit"
837
StringValue38.Parent = Script24
838
Animation39.Name = "SitAnim"
839
Animation39.Parent = StringValue38
840
Animation39.AnimationId = "http://www.roblox.com/asset/?id=178130996"
841
StringValue40.Name = "toolnone"
842
StringValue40.Parent = Script24
843
Animation41.Name = "ToolNoneAnim"
844
Animation41.Parent = StringValue40
845
Animation41.AnimationId = "http://www.roblox.com/asset/?id=182393478"
846
StringValue42.Name = "walk"
847
StringValue42.Parent = Script24
848
Animation43.Name = "WalkAnim"
849
Animation43.Parent = StringValue42
850
Animation43.AnimationId = "http://www.roblox.com/asset/?id=180426354"
851
Sound44.Name = "Cardboard"
852
Sound44.Parent = Model0
853
Sound44.SoundId = "rbxassetid://409476963"
854
Sound44.Volume = 1
855
Sound44.Looped = true
856
Script45.Name = "StomedyMain"
857
Script45.Parent = Model0
858
table.insert(cors,sandbox(Script45,function()
859
--[[ By: Brutez. ]]--
860
local StomedyScript=script;
861
repeat Wait(0)until StomedyScript and StomedyScript.Parent and StomedyScript.Parent:IsA("Model")and StomedyScript.Parent:FindFirstChild("Head")and StomedyScript.Parent:FindFirstChild("Torso");
862
local Stomedy=StomedyScript.Parent;
863
function raycast(Spos,vec,currentdist)
864
local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(Spos+(vec*.05),vec*currentdist),Stomedy);
865
if hit2~=nil and pos2 then
866
if hit2.Name=="Handle" and not hit2.CanCollide or string.sub(hit2.Name,1,6)=="Effect"and not hit2.CanCollide then
867
local currentdist=currentdist-(pos2-Spos).magnitude;
868
return raycast(pos2,vec,currentdist);
869
end;
870
end;
871
return hit2,pos2;
872
end;
873
function RayCast(Position,Direction,MaxDistance,IgnoreList)
874
return Game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(Position,Direction.unit*(MaxDistance or 999.999)),IgnoreList);
875
end;
876
local StomedyHumanoid;
877
for _,Child in pairs(Stomedy:GetChildren())do
878
if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
879
StomedyHumanoid=Child;
880
end;
881
end;
882
local AttackDebounce=false;
883
local StomedyHead=Stomedy:FindFirstChild("Head");
884
local StomedyHumanoidRootPart=Stomedy:FindFirstChild("HumanoidRootPart");
885
local WalkDebounce=false;
886
local DynamicWander=true;
887
local MusicDebounce=false;
888
local OriginalC0;
889
if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
890
Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0,1,0,1,-0);
891
OriginalC0=Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0;
892
end;
893
function FindNearestBae()
894
local NoticeDistance=200;
895
local TargetMain;
896
for _,TargetModel in pairs(Game:GetService("Workspace"):GetChildren())do
897
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and TargetModel:IsA("Model")and TargetModel~=Stomedy and TargetModel.Name~=Stomedy.Name and TargetModel:FindFirstChild("Torso")and TargetModel:FindFirstChild("Head")then
898
local TargetPart=TargetModel:FindFirstChild("Torso");
899
local FoundHumanoid;
900
for _,Child in pairs(TargetModel:GetChildren())do
901
if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
902
FoundHumanoid=Child;
903
end;
904
end;
905
if TargetModel~=nil and TargetPart~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(TargetPart.Position-StomedyHumanoidRootPart.Position).magnitude<NoticeDistance then
906
TargetMain=TargetPart;
907
NoticeDistance=(TargetPart.Position-StomedyHumanoidRootPart.Position).magnitude;
908
end;
909
end;
910
end;
911
return TargetMain;
912
end;
913
while Wait(0)do
914
if StomedyScript~=nil and Stomedy~=nil and StomedyHead~=nil and StomedyHead:FindFirstChild("StomedyMain")and not StomedyHead:FindFirstChild("StomedyMain").IsPlaying then
915
StomedyHead:FindFirstChild("StomedyMain"):Play();
916
end;
917
local TargetPoint=StomedyHumanoid.TargetPoint;
918
local Blockage,BlockagePos=RayCast((StomedyHumanoidRootPart.CFrame+CFrame.new(StomedyHumanoidRootPart.Position,Vector3.new(TargetPoint.X,StomedyHumanoidRootPart.Position.Y,TargetPoint.Z)).lookVector*(StomedyHumanoidRootPart.Size.Z/2)).p,StomedyHumanoidRootPart.CFrame.lookVector,(StomedyHumanoidRootPart.Size.Z*2.5),{Stomedy,Stomedy})
919
local Jumpable=false;
920
local MainTarget=FindNearestBae();
921
local BlockageHumanoid;
922
if Blockage~=nil then
923
if Blockage~=nil and Blockage.Parent~=nil and Blockage.Parent:IsA("Model")then
924
for _,Child in pairs(Blockage.Parent:GetChildren())do
925
if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
926
BlockageHumanoid=Child;
927
end;
928
end;
929
end;
930
Jumpable=true;
931
if Blockage and Blockage:IsA("Terrain")then
932
local CellPos=Blockage:WorldToCellPreferSolid((BlockagePos-Vector3.new(0,2,0)));
933
local CellMaterial,CellShape,CellOrientation=Blockage:GetCell(CellPos.X,CellPos.Y,CellPos.Z);
934
if CellMaterial==Enum.CellMaterial.Water or MainTarget and Blockage:IsDescendantOf(MainTarget.Parent)or BlockageHumanoid~=nil then
935
Jumpable=false;
936
end;
937
elseif Blockage.ClassName=="TrussPart"or Blockage.ClassName=="WedgePart"or Blockage.Name=="Handle"and Blockage.Parent:IsA("Hat")or Blockage.Name=="Handle"and Blockage.Parent:IsA("Tool")or MainTarget and Blockage:IsDescendantOf(MainTarget.Parent)or BlockageHumanoid~=nil then
938
Jumpable=false;
939
end;
940
end;
941
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and not StomedyHumanoid.Sit and Jumpable then
942
StomedyHumanoid.Jump=true;
943
end;
944
if StomedyScript and Stomedy and StomedyHead and StomedyHumanoidRootPart and StomedyHead:FindFirstChild("StomedyStep")and (StomedyHumanoidRootPart.Velocity-Vector3.new(0,StomedyHumanoidRootPart.Velocity.y,0)).magnitude>=5 and not WalkDebounce and StomedyHumanoid and StomedyHumanoid.Health~=0 then
945
Spawn(function()
946
WalkDebounce=true;
947
local FiredRay=Ray.new(StomedyHumanoidRootPart.Position,Vector3.new(0,-4,0));
948
local RayTarget,endPoint=Game:GetService("Workspace"):FindPartOnRay(FiredRay,Stomedy);
949
if RayTarget then
950
local StomedyHeadFootStepClone=StomedyHead:FindFirstChild("StomedyStep"):Clone();
951
StomedyHeadFootStepClone.Parent=StomedyHead;
952
StomedyHeadFootStepClone:Play();
953
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and StomedyHumanoid.WalkSpeed<17 then
954
Wait(0.4);
955
elseif StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and StomedyHumanoid.WalkSpeed>17 then
956
Wait(0.15);
957
end
958
end;
959
WalkDebounce=false;
960
end);
961
end;
962
local MainTarget=FindNearestBae();
963
local FoundHumanoid;
964
if MainTarget~=nil then
965
for _,Child in pairs(MainTarget.Parent:GetChildren())do
966
if Child~=nil and Child:IsA("Humanoid")and Child.Health~=0 then
967
FoundHumanoid=Child;
968
end;
969
end;
970
end;
971
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and MainTarget.Parent and FoundHumanoid~=nil and FoundHumanoid.Jump then
972
StomedyHumanoid.Jump=true;
973
end;
974
if not AttackDebounce and StomedyScript~=nil and Stomedy~=nil and StomedyHumanoid~=nil and StomedyHumanoid.Health~=0 and StomedyHead~=nil and StomedyHead:FindFirstChild("StomedyHit")and MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<6 then
975
local hit,pos=raycast(StomedyHumanoidRootPart.Position,(MainTarget.Position-StomedyHumanoidRootPart.Position).unit,500)
976
if hit~=nil and hit:IsDescendantOf(MainTarget.Parent)then
977
Spawn(function()
978
AttackDebounce=true;
979
local SwingAnimation=StomedyHumanoid:LoadAnimation(StomedyScript:FindFirstChild("Swing"));
980
SwingAnimation:Play();
981
SwingAnimation:AdjustSpeed(2+math.random()*0.6)
982
local HitSoundClone=StomedyHead:FindFirstChild("StomedyHit"):Clone();
983
HitSoundClone.Pitch=StomedyHead:FindFirstChild("StomedyHit").Pitch+math.random()*0.1;
984
HitSoundClone.Parent=StomedyHead;
985
HitSoundClone:Play();
986
FoundHumanoid:TakeDamage(10);
987
Wait(0.2+math.random()*0.2);
988
AttackDebounce=false;
989
end);
990
end;
991
end;
992
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<150 then
993
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")and not Stomedy:FindFirstChild("Cardboard").IsPlaying then
994
Stomedy:FindFirstChild("Cardboard").Volume=1;
995
Stomedy:FindFirstChild("Cardboard"):Play();
996
end;
997
elseif StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 and MainTarget and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude>150 then
998
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")and Stomedy:FindFirstChild("Cardboard").IsPlaying then
999
if not MusicDebounce then
1000
Spawn(function()
1001
MusicDebounce=true;
1002
repeat Wait(0);if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then Stomedy:FindFirstChild("Cardboard").Volume=Stomedy:FindFirstChild("Cardboard").Volume-0.01;else break;end;until Stomedy:FindFirstChild("Cardboard").Volume==0 or Stomedy:FindFirstChild("Cardboard").Volume<0;
1003
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then
1004
Stomedy:FindFirstChild("Cardboard").Volume=0;
1005
Stomedy:FindFirstChild("Cardboard"):Stop();
1006
end;
1007
MusicDebounce=false;
1008
end);
1009
end;
1010
end;
1011
end;
1012
if not MainTarget and not MusicDebounce then
1013
Spawn(function()
1014
MusicDebounce=true;
1015
repeat Wait(0);if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then Stomedy:FindFirstChild("Cardboard").Volume=Stomedy:FindFirstChild("Cardboard").Volume-0.01;else break;end;until Stomedy:FindFirstChild("Cardboard").Volume==0 or Stomedy:FindFirstChild("Cardboard").Volume<0;
1016
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Cardboard")then
1017
Stomedy:FindFirstChild("Cardboard").Volume=0;
1018
Stomedy:FindFirstChild("Cardboard"):Stop();
1019
end;
1020
MusicDebounce=false;
1021
end);
1022
end;
1023
if MainTarget~=nil then
1024
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Health~=0 then
1025
if MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude>5 then
1026
StomedyHumanoid.WalkSpeed=50;
1027
elseif MainTarget~=nil and FoundHumanoid~=nil and FoundHumanoid.Health~=0 and(MainTarget.Position-StomedyHumanoidRootPart.Position).magnitude<5 then
1028
StomedyHumanoid.WalkSpeed=10;
1029
end;
1030
end;
1031
if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
1032
local NeckRotation=(Stomedy:FindFirstChild("Torso").Position.Y-MainTarget.Parent:FindFirstChild("Head").Position.Y)/10;
1033
if NeckRotation>-1.5 and NeckRotation<1.5 then
1034
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
1035
Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=OriginalC0*CFrame.fromEulerAnglesXYZ(NeckRotation,0,0);
1036
end;
1037
end;
1038
if NeckRotation<-1.5 then
1039
Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,-0.993636549,0.112633869,0,0.112633869,0.993636549);
1040
elseif NeckRotation>1.5 then
1041
if StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
1042
Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0.996671617,0.081521146,0,0.081521146,-0.996671617);
1043
end;
1044
end;
1045
end;
1046
else
1047
if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Points")then
1048
local PointsModel=Stomedy:FindFirstChild("Points");
1049
if PointsModel~=nil and #PointsModel:GetChildren()~=0 then
1050
PointsModel:ClearAllChildren();
1051
end;
1052
end;
1053
if StomedyScript~=nil and Stomedy~=nil and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck")then
1054
Stomedy:FindFirstChild("Torso"):FindFirstChild("Neck").C0=CFrame.new(0,1,0,-1,0,0,0,0,1,0,1,-0);
1055
end;
1056
if StomedyScript and Stomedy and StomedyHumanoid then
1057
StomedyHumanoid.WalkSpeed=12;
1058
end;
1059
local SwitchWander=math.random(1,2000);
1060
if SwitchWander==1 and not DynamicWander then
1061
DynamicWander=true;
1062
elseif SwitchWander==1 and DynamicWander then
1063
DynamicWander=false;
1064
end;
1065
local WalkChance=math.random(1,40);
1066
if WalkChance==1 and StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Head")and StomedyHumanoid and StomedyHumanoid.Health>0.001 and not DynamicWander then
1067
elseif StomedyScript and Stomedy and Stomedy:FindFirstChild("Torso")and Stomedy:FindFirstChild("Head")and StomedyHumanoid and StomedyHumanoid.Health>0.001 and DynamicWander then
1068
local WanderAngle=(math.random()-0.5)*1;
1069
local RotatingLookVector=CFrame.Angles(0,WanderAngle,0)*script.Parent.Torso.CFrame.lookVector;
1070
StomedyHumanoid:MoveTo(Stomedy:FindFirstChild("Torso").Position+6*RotatingLookVector,Stomedy:FindFirstChild("Torso"));
1071
end;
1072
end;
1073
if StomedyScript and Stomedy and StomedyHumanoid then
1074
StomedyHumanoid.DisplayDistanceType="None";
1075
StomedyHumanoid.HealthDisplayDistance=0;
1076
StomedyHumanoid.NameDisplayDistance=0;
1077
StomedyHumanoid.NameOcclusion="EnemyOcclusion";
1078
StomedyHumanoid.AutoJumpEnabled=true;
1079
StomedyHumanoid.AutoRotate=true;
1080
StomedyHumanoid.MaxHealth=99999e99999;
1081
StomedyHumanoid.Health=99999e99999;
1082
StomedyHumanoid.JumpPower=100;
1083
StomedyHumanoid.MaxSlopeAngle=89.9;
1084
end;
1085
if StomedyScript and Stomedy and StomedyHumanoid and not StomedyHumanoid.AutoJumpEnabled then
1086
StomedyHumanoid.AutoJumpEnabled=true;
1087
end;
1088
if StomedyScript and Stomedy and StomedyHumanoid and not StomedyHumanoid.AutoRotate then
1089
StomedyHumanoid.AutoRotate=true;
1090
end;
1091
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.PlatformStand then
1092
StomedyHumanoid.PlatformStand=false;
1093
end;
1094
if StomedyScript and Stomedy and StomedyHumanoid and StomedyHumanoid.Sit then
1095
StomedyHumanoid.Sit=false;
1096
end;
1097
end;
1098
--[[ By: Brutez. ]]--
1099
end))
1100
Animation46.Name = "Swing"
1101
Animation46.Parent = Script45
1102
Animation46.AnimationId = "rbxassetid://191123156"
1103
CharacterMesh47.Name = "Roblox 3.0 Right Leg"
1104
CharacterMesh47.Parent = Model0
1105
CharacterMesh47.MeshId = 81487710
1106
CharacterMesh47.BodyPart = Enum.BodyPart.RightLeg
1107
CharacterMesh48.Name = "Roblox 3.0 torso"
1108
CharacterMesh48.Parent = Model0
1109
CharacterMesh48.MeshId = 82907945
1110
CharacterMesh48.BodyPart = Enum.BodyPart.Torso
1111
CharacterMesh49.Name = "Roblox 3.0 Left Arm"
1112
CharacterMesh49.Parent = Model0
1113
CharacterMesh49.MeshId = 82907977
1114
CharacterMesh49.BodyPart = Enum.BodyPart.LeftArm
1115
CharacterMesh50.Name = "Roblox 3.0 Left Leg"
1116
CharacterMesh50.Parent = Model0
1117
CharacterMesh50.MeshId = 81487640
1118
CharacterMesh50.BodyPart = Enum.BodyPart.LeftLeg
1119
CharacterMesh51.Name = "Roblox 3.0 Right Arm"
1120
CharacterMesh51.Parent = Model0
1121
CharacterMesh51.MeshId = 82908019
1122
CharacterMesh51.BodyPart = Enum.BodyPart.RightArm
1123
Shirt52.Name = "Shirt"
1124
Shirt52.Parent = Model0
1125
Shirt52.ShirtTemplate = "http://www.roblox.com/asset/?id=359526867"
1126
Pants53.Name = "Pants"
1127
Pants53.Parent = Model0
1128
Pants53.PantsTemplate = "http://www.roblox.com/asset/?id=242081979"
1129
Hat54.Name = "RoboKnitHat"
1130
Hat54.Parent = Model0
1131
Hat54.AttachmentPos = Vector3.new(0, 0.200000003, 0)
1132
Part55.Name = "Handle"
1133
Part55.Parent = Hat54
1134
Part55.Rotation = Vector3.new(0, -57.8199997, 0)
1135
Part55.Velocity = Vector3.new(1.40129846e-45, 0, 1.40129846e-45)
1136
Part55.CanCollide = false
1137
Part55.Locked = true
1138
Part55.FormFactor = Enum.FormFactor.Custom
1139
Part55.Size = Vector3.new(1.84000015, 1.79000008, 2.03999972)
1140
Part55.CFrame = CFrame.new(20.9954529, 4.80000925, 7.42480421, 0.53263253, 0, -0.846346557, 0, 1, 0, 0.846346557, 0, 0.53263253)
1141
Part55.BottomSurface = Enum.SurfaceType.Smooth
1142
Part55.TopSurface = Enum.SurfaceType.Smooth
1143
Part55.Position = Vector3.new(20.9954529, 4.80000925, 7.42480421)
1144
Part55.Orientation = Vector3.new(0, -57.8199997, 0)
1145
SpecialMesh56.Parent = Part55
1146
SpecialMesh56.MeshId = "http://www.roblox.com/asset/?id=215693829 "
1147
SpecialMesh56.TextureId = "http://www.roblox.com/asset/?id=215694384  "
1148
SpecialMesh56.MeshType = Enum.MeshType.FileMesh
1149
Script57.Name = "MonsterScript"
1150
Script57.Parent = Model0
1151
table.insert(cors,sandbox(Script57,function()
1152
--[[
1153
	Basic Monster by ArceusInator
1154
1155
	Information:
1156
		Configurations.MaximumDetectionDistance (default 200)
1157
			The monster will not detect players past this point.  If you set it to a negative number then the monster will be able to chase from any distance.
1158
			
1159
		Configurations.CanGiveUp (default true)
1160
			If true, the monster will give up if its target goes past the MaximumDetectionDistance.  This is a pretty good idea if you have people teleporting around.
1161
			
1162
		Configurations.CanRespawn (default true)
1163
			If true, the monster will respawn after it dies
1164
			
1165
		Configurations.AutoDetectSpawnPoint (default true)
1166
			If true, the spawn point will be auto detected based on where the monster is when it starts
1167
		
1168
		Configurations.SpawnPoint (default 0,0,0)
1169
			If Settings.AutoDetectSpawnPoint is disabled, this will be set to the monster's initial position.  This value will be used when the monster auto respawns to tell it where to spawn next.
1170
			
1171
		Configurations.FriendlyTeam (default Really black)
1172
			The monster will not attack players on this team
1173
		
1174
		
1175
		
1176
		Mind.CurrentTargetHumanoid (Humanoid objects only)
1177
			You can force the monster to follow a certain humanoid by setting this to that humanoid
1178
		
1179
		
1180
		
1181
		Monster.Respawn (Function)
1182
			Arguments are: Vector3 point
1183
			Info: Respawns the monster at the given point, or at the SpawnPoint setting if none if provided
1184
		
1185
		Monster.Died (Event)
1186
			Info: Fired when the monster dies
1187
		
1188
		Monster.Respawned (Event)
1189
			Info: Fired when the monster respawns
1190
--]]
1191
1192
local Self = script.Parent
1193
local Settings = Self:FindFirstChild'Configurations' -- Points to the settings.
1194
local Mind = Self:FindFirstChild'Mind' -- Points to the monster's mind.  You can edit parts of this from other scripts in-game to change the monster's behavior.  Advanced users only.
1195
1196
--
1197
-- Verify that everything is where it should be
1198
assert(Self:FindFirstChild'Humanoid' ~= nil, 'Monster does not have a humanoid')
1199
assert(Settings ~= nil, 'Monster does not have a Configurations object')
1200
	assert(Settings:FindFirstChild'MaximumDetectionDistance' ~= nil and Settings.MaximumDetectionDistance:IsA'NumberValue', 'Monster does not have a MaximumDetectionDistance (NumberValue) setting')
1201
	assert(Settings:FindFirstChild'CanGiveUp' ~= nil and Settings.CanGiveUp:IsA'BoolValue', 'Monster does not have a CanGiveUp (BoolValue) setting')
1202
	assert(Settings:FindFirstChild'CanRespawn' ~= nil and Settings.CanRespawn:IsA'BoolValue', 'Monster does not have a CanRespawn (BoolValue) setting')
1203
	assert(Settings:FindFirstChild'SpawnPoint' ~= nil and Settings.SpawnPoint:IsA'Vector3Value', 'Monster does not have a SpawnPoint (Vector3Value) setting')
1204
	assert(Settings:FindFirstChild'AutoDetectSpawnPoint' ~= nil and Settings.AutoDetectSpawnPoint:IsA'BoolValue', 'Monster does not have a AutoDetectSpawnPoint (BoolValue) setting')
1205
	assert(Settings:FindFirstChild'FriendlyTeam' ~= nil and Settings.FriendlyTeam:IsA'BrickColorValue', 'Monster does not have a FriendlyTeam (BrickColorValue) setting')
1206
	assert(Settings:FindFirstChild'AttackDamage' ~= nil and Settings.AttackDamage:IsA'NumberValue', 'Monster does not have a AttackDamage (NumberValue) setting')
1207
	assert(Settings:FindFirstChild'AttackFrequency' ~= nil and Settings.AttackFrequency:IsA'NumberValue', 'Monster does not have a AttackFrequency (NumberValue) setting')
1208
	assert(Settings:FindFirstChild'AttackRange' ~= nil and Settings.AttackRange:IsA'NumberValue', 'Monster does not have a AttackRange (NumberValue) setting')
1209
assert(Mind ~= nil, 'Monster does not have a Mind object')
1210
	assert(Mind:FindFirstChild'CurrentTargetHumanoid' ~= nil and Mind.CurrentTargetHumanoid:IsA'ObjectValue', 'Monster does not have a CurrentTargetHumanoid (ObjectValue) mind setting')
1211
assert(Self:FindFirstChild'Respawn' and Self.Respawn:IsA'BindableFunction', 'Monster does not have a Respawn BindableFunction')
1212
assert(Self:FindFirstChild'Died' and Self.Died:IsA'BindableEvent', 'Monster does not have a Died BindableEvent')
1213
assert(Self:FindFirstChild'Respawned' and Self.Died:IsA'BindableEvent', 'Monster does not have a Respawned BindableEvent')
1214
assert(Self:FindFirstChild'Attacked' and Self.Died:IsA'BindableEvent', 'Monster does not have a Attacked BindableEvent')
1215
assert(script:FindFirstChild'Attack' and script.Attack:IsA'Animation', 'Monster does not have a MonsterScript.Attack Animation')
1216
1217
1218
--
1219
--
1220
local Info = {
1221
	-- These are constant values.  Don't change them unless you know what you're doing.
1222
1223
	-- Services
1224
	Players = Game:GetService 'Players',
1225
	PathfindingService = Game:GetService 'PathfindingService',
1226
1227
	-- Advanced settings
1228
	RecomputePathFrequency = 1, -- The monster will recompute its path this many times per second
1229
	RespawnWaitTime = 5, -- How long to wait before the monster respawns
1230
	JumpCheckFrequency = 1, -- How many times per second it will do a jump check
1231
}
1232
local Data = {
1233
	-- These are variable values used internally by the script.  Advanced users only.
1234
1235
	LastRecomputePath = 0,
1236
	Recomputing = false, -- Reocmputing occurs async, meaning this script will still run while it's happening.  This variable will prevent the script from running two recomputes at once.
1237
	PathCoords = {},
1238
	IsDead = false,
1239
	TimeOfDeath = 0,
1240
	CurrentNode = nil,
1241
	CurrentNodeIndex = 1,
1242
	AutoRecompute = true,
1243
	LastJumpCheck = 0,
1244
	LastAttack = 0,
1245
	
1246
	BaseMonster = Self:Clone(),
1247
	AttackTrack = nil,
1248
}
1249
1250
--
1251
--
1252
local Monster = {} -- Create the monster class
1253
1254
1255
function Monster:GetCFrame()
1256
	-- Returns the CFrame of the monster's humanoidrootpart
1257
1258
	local humanoidRootPart = Self:FindFirstChild('HumanoidRootPart')
1259
1260
	if humanoidRootPart ~= nil and humanoidRootPart:IsA('BasePart') then
1261
		return humanoidRootPart.CFrame
1262
	else
1263
		return CFrame.new()
1264
	end
1265
end
1266
1267
function Monster:GetMaximumDetectionDistance()
1268
	-- Returns the maximum detection distance
1269
	
1270
	local setting = Settings.MaximumDetectionDistance.Value
1271
1272
	if setting < 0 then
1273
		return math.huge
1274
	else
1275
		return setting
1276
	end
1277
end
1278
1279
function Monster:SearchForTarget()
1280
	-- Finds the closest player and sets the target
1281
1282
	local players = Info.Players:GetPlayers()
1283
	local closestCharacter, closestCharacterDistance
1284
1285
	for i=1, #players do
1286
		local player = players[i]
1287
		
1288
		if player.Neutral or player.TeamColor ~= Settings.FriendlyTeam.Value then
1289
			local character = player.Character
1290
	
1291
			if character ~= nil and character:FindFirstChild('Humanoid') ~= nil and character.Humanoid:IsA('Humanoid') then
1292
				local distance = player:DistanceFromCharacter(Monster:GetCFrame().p)
1293
	
1294
				if distance < Monster:GetMaximumDetectionDistance() then
1295
					if closestCharacter == nil then
1296
						closestCharacter, closestCharacterDistance = character, distance
1297
					else
1298
						if closestCharacterDistance > distance then
1299
							closestCharacter, closestCharacterDistance = character, distance
1300
						end
1301
					end
1302
				end
1303
			end
1304
		end
1305
	end
1306
1307
1308
	if closestCharacter ~= nil then
1309
		Mind.CurrentTargetHumanoid.Value = closestCharacter.Humanoid
1310
	end
1311
end
1312
1313
function Monster:TryRecomputePath()
1314
	if Data.AutoRecompute or tick() - Data.LastRecomputePath > 1/Info.RecomputePathFrequency then
1315
		Monster:RecomputePath()
1316
	end
1317
end
1318
1319
function Monster:GetTargetCFrame()
1320
	local targetHumanoid = Mind.CurrentTargetHumanoid.Value
1321
	
1322
	if Monster:TargetIsValid() then
1323
		return targetHumanoid.Torso.CFrame
1324
	else
1325
		return CFrame.new()
1326
	end
1327
end
1328
1329
function Monster:IsAlive()
1330
	return Self.Humanoid.Health > 0 and Self.Humanoid.Torso ~= nil
1331
end
1332
1333
function Monster:TargetIsValid()
1334
	local targetHumanoid = Mind.CurrentTargetHumanoid.Value
1335
	
1336
	if targetHumanoid ~= nil and targetHumanoid:IsA 'Humanoid' and targetHumanoid.Torso ~= nil and targetHumanoid.Torso:IsA 'BasePart' then
1337
		return true
1338
	else
1339
		return false
1340
	end
1341
end
1342
1343
function Monster:HasClearLineOfSight()
1344
	-- Going to cast a ray to see if I can just see my target
1345
	local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
1346
	
1347
	local hit, pos = Workspace:FindPartOnRayWithIgnoreList(
1348
		Ray.new(
1349
			myPos,
1350
			targetPos - myPos
1351
		),
1352
		{
1353
			Self,
1354
			Mind.CurrentTargetHumanoid.Value.Parent
1355
		}
1356
	)
1357
	
1358
	
1359
	if hit == nil then
1360
		return true
1361
	else
1362
		return false
1363
	end
1364
end
1365
1366
function Monster:RecomputePath()
1367
	if not Data.Recomputing then
1368
		if Monster:IsAlive() and Monster:TargetIsValid() then
1369
			if Monster:HasClearLineOfSight() then
1370
				Data.AutoRecompute = true
1371
				Data.PathCoords = {
1372
					Monster:GetCFrame().p,
1373
					Monster:GetTargetCFrame().p
1374
				}
1375
				
1376
				Data.LastRecomputePath = tick()
1377
				Data.CurrentNode = nil
1378
				Data.CurrentNodeIndex = 2 -- Starts chasing the target without evaluating its current position
1379
			else
1380
				-- Do pathfinding since you can't walk straight
1381
				Data.Recomputing = true -- Basically a debounce.
1382
				Data.AutoRecompute = false
1383
				
1384
				
1385
				local path = Info.PathfindingService:ComputeSmoothPathAsync(
1386
					Monster:GetCFrame().p,
1387
					Monster:GetTargetCFrame().p,
1388
					500
1389
				)
1390
				Data.PathCoords = path:GetPointCoordinates()
1391
				
1392
				
1393
				Data.Recomputing = false
1394
				Data.LastRecomputePath = tick()
1395
				Data.CurrentNode = nil
1396
				Data.CurrentNodeIndex = 1
1397
			end
1398
		end
1399
	end
1400
end
1401
1402
function Monster:Update()
1403
	Monster:ReevaluateTarget()
1404
	Monster:SearchForTarget()
1405
	Monster:TryRecomputePath()
1406
	Monster:TravelPath()
1407
end
1408
1409
function Monster:TravelPath()
1410
	local closest, closestDistance, closestIndex
1411
	local myPosition = Monster:GetCFrame().p
1412
	local skipCurrentNode = Data.CurrentNode ~= nil and (Data.CurrentNode - myPosition).magnitude < 3
1413
	
1414
	for i=Data.CurrentNodeIndex, #Data.PathCoords do
1415
		local coord = Data.PathCoords[i]
1416
		if not (skipCurrentNode and coord == Data.CurrentNode) then
1417
			local distance = (coord - myPosition).magnitude
1418
			
1419
			if closest == nil then
1420
				closest, closestDistance, closestIndex = coord, distance, i
1421
			else
1422
				if distance < closestDistance then
1423
					closest, closestDistance, closestIndex = coord, distance, i
1424
				else
1425
					break
1426
				end
1427
			end
1428
		end
1429
	end
1430
	
1431
	
1432
	--
1433
	if closest ~= nil then
1434
		Data.CurrentNode = closest
1435
		Data.CurrentNodeIndex = closestIndex
1436
		
1437
		local humanoid = Self:FindFirstChild 'Humanoid'
1438
		
1439
		if humanoid ~= nil and humanoid:IsA'Humanoid' then
1440
			humanoid:MoveTo(closest)
1441
		end
1442
		
1443
		if Monster:IsAlive() and Monster:TargetIsValid() then
1444
			Monster:TryJumpCheck()
1445
			Monster:TryAttack()
1446
		end
1447
		
1448
		if closestIndex == #Data.PathCoords then
1449
			-- Reached the end of the path, force a new check
1450
			Data.AutoRecompute = true
1451
		end
1452
	end
1453
end
1454
1455
function Monster:TryJumpCheck()
1456
	if tick() - Data.LastJumpCheck > 1/Info.JumpCheckFrequency then
1457
		Monster:JumpCheck()
1458
	end
1459
end
1460
1461
function Monster:TryAttack()
1462
	if tick() - Data.LastAttack > 1/Settings.AttackFrequency.Value then
1463
		Monster:Attack()
1464
	end
1465
end
1466
1467
function Monster:Attack()
1468
	local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
1469
	
1470
	if (myPos - targetPos).magnitude <= Settings.AttackRange.Value then
1471
		Mind.CurrentTargetHumanoid.Value:TakeDamage(Settings.AttackDamage.Value)
1472
		Data.LastAttack = tick()
1473
		Data.AttackTrack:Play()
1474
	end
1475
end
1476
1477
function Monster:JumpCheck()
1478
	-- Do a raycast to check if we need to jump
1479
	local myCFrame = Monster:GetCFrame()
1480
	local checkVector = (Monster:GetTargetCFrame().p - myCFrame.p).unit*2
1481
	
1482
	local hit, pos = Workspace:FindPartOnRay(
1483
		Ray.new(
1484
			myCFrame.p + Vector3.new(0, -2.4, 0),
1485
			checkVector
1486
		),
1487
		Self
1488
	)
1489
	
1490
	if hit ~= nil and not hit:IsDescendantOf(Mind.CurrentTargetHumanoid.Value.Parent) then
1491
		-- Do a slope check to make sure we're not walking up a ramp
1492
		
1493
		local hit2, pos2 = Workspace:FindPartOnRay(
1494
			Ray.new(
1495
				myCFrame.p + Vector3.new(0, -2.3, 0),
1496
				checkVector
1497
			),
1498
			Self
1499
		)
1500
		
1501
		if hit2 == hit then
1502
			if ((pos2 - pos)*Vector3.new(1,0,1)).magnitude < 0.05 then -- Will pass for any ramp with <2 slope
1503
				Self.Humanoid.Jump = true
1504
			end
1505
		end
1506
	end
1507
	
1508
	Data.LastJumpCheck = tick()
1509
end
1510
1511
function Monster:Connect()
1512
	Mind.CurrentTargetHumanoid.Changed:connect(function(humanoid)
1513
		if humanoid ~= nil then
1514
			assert(humanoid:IsA'Humanoid', 'Monster target must be a humanoid')
1515
			
1516
			Monster:RecomputePath()
1517
		end
1518
	end)
1519
	
1520
	Self.Respawn.OnInvoke = function(point)
1521
		Monster:Respawn(point)
1522
	end
1523
end
1524
1525
function Monster:Initialize()
1526
	Monster:Connect()
1527
	
1528
	if Settings.AutoDetectSpawnPoint.Value then
1529
		Settings.SpawnPoint.Value = Monster:GetCFrame().p
1530
	end
1531
end
1532
1533
function Monster:Respawn(point)
1534
	local point = point or Settings.SpawnPoint.Value
1535
	
1536
	for index, obj in next, Data.BaseMonster:Clone():GetChildren() do
1537
		if obj.Name == 'Configurations' or obj.Name == 'Mind' or obj.Name == 'Respawned' or obj.Name == 'Died' or obj.Name == 'MonsterScript' or obj.Name == 'Respawn' then
1538
			obj:Destroy()
1539
		else
1540
			Self[obj.Name]:Destroy()
1541
			obj.Parent = Self
1542
		end
1543
	end
1544
	
1545
	Monster:InitializeUnique()
1546
	
1547
	Self.Parent = Workspace
1548
	
1549
	Self.HumanoidRootPart.CFrame = CFrame.new(point)
1550
	Settings.SpawnPoint.Value = point
1551
	Self.Respawned:Fire()
1552
end
1553
1554
function Monster:InitializeUnique()
1555
	Data.AttackTrack = Self.Humanoid:LoadAnimation(script.Attack)
1556
end
1557
1558
function Monster:ReevaluateTarget()
1559
	local currentTarget = Mind.CurrentTargetHumanoid.Value
1560
	
1561
	if currentTarget ~= nil and currentTarget:IsA'Humanoid' then
1562
		local character = currentTarget.Parent
1563
		
1564
		if character ~= nil then
1565
			local player = Info.Players:GetPlayerFromCharacter(character)
1566
			
1567
			if player ~= nil then
1568
				if not player.Neutral and player.TeamColor == Settings.FriendlyTeam.Value then
1569
					Mind.CurrentTargetHumanoid.Value = nil
1570
				end
1571
			end
1572
		end
1573
		
1574
		
1575
		if currentTarget == Mind.CurrentTargetHumanoid.Value then
1576
			local torso = currentTarget.Torso
1577
			
1578
			if torso ~= nil and torso:IsA 'BasePart' then
1579
				if Settings.CanGiveUp.Value and (torso.Position - Monster:GetCFrame().p).magnitude > Monster:GetMaximumDetectionDistance() then
1580
					Mind.CurrentTargetHumanoid.Value = nil
1581
				end
1582
			end
1583
		end
1584
	end
1585
end
1586
1587
--
1588
--
1589
Monster:Initialize()
1590
Monster:InitializeUnique()
1591
1592
while true do
1593
	if not Monster:IsAlive() then
1594
		if Data.IsDead == false then
1595
			Data.IsDead = true
1596
			Data.TimeOfDeath = tick()
1597
			Self.Died:Fire()
1598
		end
1599
		if Data.IsDead == true then
1600
			if tick()-Data.TimeOfDeath > Info.RespawnWaitTime then
1601
				Monster:Respawn()
1602
			end
1603
		end
1604
	end
1605
	
1606
	if Monster:IsAlive() then
1607
		Monster:Update()
1608
	end
1609
	
1610
	wait()
1611
end
1612
end))
1613
Animation58.Name = "Attack"
1614
Animation58.Parent = Script57
1615
Animation58.AnimationId = "rbxassetid://0"
1616
BindableFunction59.Name = "Respawn"
1617
BindableFunction59.Parent = Model0
1618
BindableEvent60.Name = "Attacked"
1619
BindableEvent60.Parent = Model0
1620
BindableEvent61.Name = "Died"
1621
BindableEvent61.Parent = Model0
1622
BindableEvent62.Name = "Respawned"
1623
BindableEvent62.Parent = Model0
1624
Configuration63.Name = "Mind"
1625
Configuration63.Parent = Model0
1626
ObjectValue64.Name = "CurrentTargetHumanoid"
1627
ObjectValue64.Parent = Configuration63
1628
Configuration65.Name = "Configurations"
1629
Configuration65.Parent = Model0
1630
NumberValue66.Name = "MaximumDetectionDistance"
1631
NumberValue66.Parent = Configuration65
1632
NumberValue66.Value = 200
1633
BoolValue67.Name = "CanGiveUp"
1634
BoolValue67.Parent = Configuration65
1635
BoolValue67.Value = true
1636
BoolValue68.Name = "CanRespawn"
1637
BoolValue68.Parent = Configuration65
1638
BoolValue68.Value = true
1639
Vector3Value69.Name = "SpawnPoint"
1640
Vector3Value69.Parent = Configuration65
1641
Vector3Value69.Value = Vector3.new(24.2997856, 5.00000095, -33.0201225)
1642
BoolValue70.Name = "AutoDetectSpawnPoint"
1643
BoolValue70.Parent = Configuration65
1644
BoolValue70.Value = true
1645
BrickColorValue71.Name = "FriendlyTeam"
1646
BrickColorValue71.Parent = Configuration65
1647
BrickColorValue71.Value = BrickColor.new("Really black")
1648
NumberValue72.Name = "AttackDamage"
1649
NumberValue72.Parent = Configuration65
1650
NumberValue73.Name = "AttackFrequency"
1651
NumberValue73.Parent = Configuration65
1652
NumberValue73.Value = 2
1653
NumberValue74.Name = "AttackRange"
1654
NumberValue74.Parent = Configuration65
1655
NumberValue74.Value = 3
1656
for i,v in pairs(mas:GetChildren()) do
1657
	v.Parent = workspace
1658
	pcall(function() v:MakeJoints() end)
1659
end
1660
mas:Destroy()
1661
for i,v in pairs(cors) do
1662
	spawn(function()
1663
		pcall(v)
1664
	end)
1665
end