· 5 years ago · Mar 23, 2020, 10:42 PM
1
2
3function sandbox(var,func)
4 local env = getfenv(func)
5 local newenv = setmetatable({},{
6 __index = function(self,k)
7 if k=="script" then
8 return var
9 else
10 return env[k]
11 end
12 end,
13 })
14 setfenv(func,newenv)
15 return func
16end
17cors = {}
18mas = Instance.new("Model",game:GetService("Lighting"))
19Model0 = Instance.new("Model")
20BodyColors1 = Instance.new("BodyColors")
21Pants2 = Instance.new("Pants")
22Shirt3 = Instance.new("Shirt")
23Hat4 = Instance.new("Hat")
24Part5 = Instance.new("Part")
25SpecialMesh6 = Instance.new("SpecialMesh")
26Script7 = Instance.new("Script")
27Humanoid8 = Instance.new("Humanoid")
28Script9 = Instance.new("Script")
29LocalScript10 = Instance.new("LocalScript")
30Part11 = Instance.new("Part")
31SpecialMesh12 = Instance.new("SpecialMesh")
32Decal13 = Instance.new("Decal")
33Weld14 = Instance.new("Weld")
34Part15 = Instance.new("Part")
35Motor6D16 = Instance.new("Motor6D")
36Part17 = Instance.new("Part")
37Part18 = Instance.new("Part")
38Part19 = Instance.new("Part")
39Part20 = Instance.new("Part")
40SpecialMesh21 = Instance.new("SpecialMesh")
41Decal22 = Instance.new("Decal")
42Script23 = Instance.new("Script")
43Part24 = Instance.new("Part")
44Part25 = Instance.new("Part")
45Decal26 = Instance.new("Decal")
46Motor6D27 = Instance.new("Motor6D")
47Motor6D28 = Instance.new("Motor6D")
48Motor6D29 = Instance.new("Motor6D")
49Motor6D30 = Instance.new("Motor6D")
50Motor6D31 = Instance.new("Motor6D")
51Script32 = Instance.new("Script")
52Script33 = Instance.new("Script")
53StringValue34 = Instance.new("StringValue")
54Animation35 = Instance.new("Animation")
55StringValue36 = Instance.new("StringValue")
56Animation37 = Instance.new("Animation")
57StringValue38 = Instance.new("StringValue")
58Animation39 = Instance.new("Animation")
59NumberValue40 = Instance.new("NumberValue")
60Animation41 = Instance.new("Animation")
61NumberValue42 = Instance.new("NumberValue")
62StringValue43 = Instance.new("StringValue")
63Animation44 = Instance.new("Animation")
64StringValue45 = Instance.new("StringValue")
65Animation46 = Instance.new("Animation")
66StringValue47 = Instance.new("StringValue")
67Animation48 = Instance.new("Animation")
68StringValue49 = Instance.new("StringValue")
69Animation50 = Instance.new("Animation")
70StringValue51 = Instance.new("StringValue")
71Animation52 = Instance.new("Animation")
72Model0.Name = " "
73Model0.Parent = mas
74BodyColors1.Parent = Model0
75BodyColors1.HeadColor = BrickColor.new("Brick yellow")
76BodyColors1.HeadColor3 = Color3.new(0.843137, 0.772549, 0.603922)
77BodyColors1.LeftArmColor = BrickColor.new("Brick yellow")
78BodyColors1.LeftArmColor3 = Color3.new(0.843137, 0.772549, 0.603922)
79BodyColors1.LeftLegColor = BrickColor.new("Light orange")
80BodyColors1.LeftLegColor3 = Color3.new(0.917647, 0.721569, 0.572549)
81BodyColors1.RightArmColor = BrickColor.new("Brick yellow")
82BodyColors1.RightArmColor3 = Color3.new(0.843137, 0.772549, 0.603922)
83BodyColors1.RightLegColor = BrickColor.new("Light orange")
84BodyColors1.RightLegColor3 = Color3.new(0.917647, 0.721569, 0.572549)
85BodyColors1.TorsoColor = BrickColor.new("Light orange")
86BodyColors1.TorsoColor3 = Color3.new(0.917647, 0.721569, 0.572549)
87Pants2.Name = "Pants"
88Pants2.Parent = Model0
89Pants2.PantsTemplate = "http://www.roblox.com/asset/?id=231490204"
90Shirt3.Name = "Shirt"
91Shirt3.Parent = Model0
92Shirt3.ShirtTemplate = "http://www.roblox.com/asset/?id=231490189"
93Hat4.Name = "BlackCharmerHair"
94Hat4.Parent = Model0
95Hat4.AttachmentPoint = CFrame.new(0, 0.075000003, 0.0500000007, 1, 0, 0, 0, 1, 0, 0, 0, 1)
96Hat4.AttachmentPos = Vector3.new(0, 0.075000003, 0.0500000007)
97Part5.Name = "Handle"
98Part5.Parent = Hat4
99Part5.CFrame = CFrame.new(-40.5612335, 4.92494297, 35.5586319, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
100Part5.Orientation = Vector3.new(0, -172.380005, 0)
101Part5.Position = Vector3.new(-40.5612335, 4.92494297, 35.5586319)
102Part5.Rotation = Vector3.new(180, -7.61999989, -180)
103Part5.Size = Vector3.new(1.19999957, 1, 1.5999999)
104Part5.BottomSurface = Enum.SurfaceType.Smooth
105Part5.CanCollide = false
106Part5.Locked = true
107Part5.TopSurface = Enum.SurfaceType.Smooth
108Part5.FormFactor = Enum.FormFactor.Custom
109Part5.formFactor = Enum.FormFactor.Custom
110SpecialMesh6.Parent = Part5
111SpecialMesh6.MeshId = "http://www.roblox.com/asset/?id=74878559"
112SpecialMesh6.Scale = Vector3.new(1.04999995, 1, 1.04999995)
113SpecialMesh6.TextureId = "http://www.roblox.com/asset/?id=75975752"
114SpecialMesh6.MeshType = Enum.MeshType.FileMesh
115Script7.Name = "Health"
116Script7.Parent = Model0
117table.insert(cors,sandbox(Script7,function()
118--Responsible for regening a player's humanoid's health
119
120-- declarations
121local Figure = script.Parent
122local Head = Figure:WaitForChild("Head")
123local Humanoid = Figure:WaitForChild("Humanoid")
124local regening = false
125
126-- regeneration
127function regenHealth()
128 if regening then return end
129 regening = true
130
131 while Humanoid.Health < Humanoid.MaxHealth do
132 local s = wait(1)
133 local health = Humanoid.Health
134 if health > 0 and health < Humanoid.MaxHealth then
135 local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
136 health = health + newHealthDelta
137 Humanoid.Health = math.min(health,Humanoid.MaxHealth)
138 end
139 end
140
141 if Humanoid.Health > Humanoid.MaxHealth then
142 Humanoid.Health = Humanoid.MaxHealth
143 end
144
145 regening = false
146end
147
148Humanoid.HealthChanged:connect(regenHealth)
149
150end))
151Humanoid8.Parent = Model0
152Humanoid8.LeftLeg = Part18
153Humanoid8.MaxHealth = 0
154Humanoid8.NameOcclusion = Enum.NameOcclusion.NoOcclusion
155Humanoid8.RightLeg = Part24
156Humanoid8.Torso = Part15
157Humanoid8.maxHealth = 0
158Script9.Name = "Sound"
159Script9.Parent = Model0
160table.insert(cors,sandbox(Script9,function()
161---This server script creates the sounds and also exists so that it can be easily copied into an NPC and create sounds for that NPC.
162--Remove the local script if you copy this into an NPC.
163
164function waitForChild(parent, childName)
165 local child = parent:findFirstChild(childName)
166 if child then return child end
167 while true do
168 child = parent.ChildAdded:wait()
169 if child.Name==childName then return child end
170 end
171end
172
173function newSound(name, id)
174 local sound = Instance.new("Sound")
175 sound.SoundId = id
176 sound.Name = name
177 sound.archivable = false
178 sound.Parent = script.Parent.Head
179 return sound
180end
181
182-- declarations
183
184local sGettingUp = newSound("GettingUp", "rbxasset://sounds/action_get_up.mp3")
185local sDied = newSound("Died", "rbxasset://sounds/uuhhh.mp3")
186local sFreeFalling = newSound("FreeFalling", "rbxasset://sounds/action_falling.mp3")
187local sJumping = newSound("Jumping", "rbxasset://sounds/action_jump.mp3")
188local sLanding = newSound("Landing", "rbxasset://sounds/action_jump_land.mp3")
189local sSplash = newSound("Splash", "rbxasset://sounds/impact_water.mp3")
190local sRunning = newSound("Running", "rbxasset://sounds/action_footsteps_plastic.mp3")
191sRunning.Looped = true
192local sSwimming = newSound("Swimming", "rbxasset://sounds/action_swim.mp3")
193sSwimming.Looped = true
194local sClimbing = newSound("Climbing", "rbxasset://sounds/action_footsteps_plastic.mp3")
195sClimbing.Looped = true
196
197local Figure = script.Parent
198local Head = waitForChild(Figure, "Head")
199local Humanoid = waitForChild(Figure, "Humanoid")
200local hasPlayer = game.Players:GetPlayerFromCharacter(script.Parent)
201local filteringEnabled = game.Workspace.FilteringEnabled
202
203local prevState = "None"
204
205-- functions
206
207function onDied()
208 stopLoopedSounds()
209 sDied:Play()
210end
211
212local fallCount = 0
213local fallSpeed = 0
214function onStateFall(state, sound)
215 fallCount = fallCount + 1
216 if state then
217 sound.Volume = 0
218 sound:Play()
219 Spawn( function()
220 local t = 0
221 local thisFall = fallCount
222 while t < 1.5 and fallCount == thisFall do
223 local vol = math.max(t - 0.3 , 0)
224 sound.Volume = vol
225 wait(0.1)
226 t = t + 0.1
227 end
228 end)
229 else
230 sound:Stop()
231 end
232 fallSpeed = math.max(fallSpeed, math.abs(Head.Velocity.Y))
233end
234
235
236function onStateNoStop(state, sound)
237 if state then
238 sound:Play()
239 end
240end
241
242
243function onRunning(speed)
244 sClimbing:Stop()
245 sSwimming:Stop()
246 if (prevState == "FreeFall" and fallSpeed > 0.1) then
247 local vol = math.min(1.0, math.max(0.0, (fallSpeed - 50) / 110))
248 sLanding.Volume = vol
249 sLanding:Play()
250 fallSpeed = 0
251 end
252 if speed>0.5 then
253 sRunning:Play()
254 sRunning.Pitch = speed / 8.0
255 else
256 sRunning:Stop()
257 end
258 prevState = "Run"
259end
260
261function onSwimming(speed)
262 if (prevState ~= "Swim" and speed > 0.1) then
263 local volume = math.min(1.0, speed / 350)
264 sSplash.Volume = volume
265 sSplash:Play()
266 prevState = "Swim"
267 end
268 sClimbing:Stop()
269 sRunning:Stop()
270 sSwimming.Pitch = 1.6
271 sSwimming:Play()
272end
273
274function onClimbing(speed)
275 sRunning:Stop()
276 sSwimming:Stop()
277 if speed>0.01 then
278 sClimbing:Play()
279 sClimbing.Pitch = speed / 5.5
280 else
281 sClimbing:Stop()
282 end
283 prevState = "Climb"
284end
285-- connect up
286
287function stopLoopedSounds()
288 sRunning:Stop()
289 sClimbing:Stop()
290 sSwimming:Stop()
291end
292
293if hasPlayer == nil then
294 Humanoid.Died:connect(onDied)
295 Humanoid.Running:connect(onRunning)
296 Humanoid.Swimming:connect(onSwimming)
297 Humanoid.Climbing:connect(onClimbing)
298 Humanoid.Jumping:connect(function(state) onStateNoStop(state, sJumping) prevState = "Jump" end)
299 Humanoid.GettingUp:connect(function(state) stopLoopedSounds() onStateNoStop(state, sGettingUp) prevState = "GetUp" end)
300 Humanoid.FreeFalling:connect(function(state) stopLoopedSounds() onStateFall(state, sFreeFalling) prevState = "FreeFall" end)
301 Humanoid.FallingDown:connect(function(state) stopLoopedSounds() end)
302 Humanoid.StateChanged:connect(function(old, new)
303 if not (new.Name == "Dead" or
304 new.Name == "Running" or
305 new.Name == "RunningNoPhysics" or
306 new.Name == "Swimming" or
307 new.Name == "Jumping" or
308 new.Name == "GettingUp" or
309 new.Name == "Freefall" or
310 new.Name == "FallingDown") then
311 stopLoopedSounds()
312 end
313 end)
314end
315
316end))
317LocalScript10.Name = "LocalSound"
318LocalScript10.Parent = Script9
319table.insert(cors,sandbox(LocalScript10,function()
320--This local script will run only for the player whos character it is in. It's changes to the sounds will replicate as they are changes to the character.
321-- util
322
323function waitForChild(parent, childName)
324 local child = parent:findFirstChild(childName)
325 if child then return child end
326 while true do
327 child = parent.ChildAdded:wait()
328 if child.Name==childName then return child end
329 end
330end
331
332
333-- declarations
334
335local Figure = script.Parent.Parent
336local Head = waitForChild(Figure, "Head")
337local Humanoid = waitForChild(Figure, "Humanoid")
338
339local sGettingUp = waitForChild(Head, "GettingUp")
340local sDied = waitForChild(Head, "Died")
341local sFreeFalling = waitForChild(Head, "FreeFalling")
342local sJumping = waitForChild(Head, "Jumping")
343local sLanding = waitForChild(Head, "Landing")
344local sSplash = waitForChild(Head, "Splash")
345local sRunning = waitForChild(Head, "Running")
346sRunning.Looped = true
347local sSwimming = waitForChild(Head, "Swimming")
348sSwimming.Looped = true
349local sClimbing =waitForChild(Head, "Climbing")
350sClimbing.Looped = true
351
352local prevState = "None"
353
354-- functions
355
356function onDied()
357 stopLoopedSounds()
358 sDied:Play()
359end
360
361local fallCount = 0
362local fallSpeed = 0
363function onStateFall(state, sound)
364 fallCount = fallCount + 1
365 if state then
366 sound.Volume = 0
367 sound:Play()
368 Spawn( function()
369 local t = 0
370 local thisFall = fallCount
371 while t < 1.5 and fallCount == thisFall do
372 local vol = math.max(t - 0.3 , 0)
373 sound.Volume = vol
374 wait(0.1)
375 t = t + 0.1
376 end
377 end)
378 else
379 sound:Stop()
380 end
381 fallSpeed = math.max(fallSpeed, math.abs(Head.Velocity.Y))
382end
383
384
385function onStateNoStop(state, sound)
386 if state then
387 sound:Play()
388 end
389end
390
391
392function onRunning(speed)
393 sClimbing:Stop()
394 sSwimming:Stop()
395 if (prevState == "FreeFall" and fallSpeed > 0.1) then
396 local vol = math.min(1.0, math.max(0.0, (fallSpeed - 50) / 110))
397 sLanding.Volume = vol
398 sLanding:Play()
399 fallSpeed = 0
400 end
401 if speed>0.5 then
402 sRunning:Play()
403 sRunning.Pitch = speed / 8.0
404 else
405 sRunning:Stop()
406 end
407 prevState = "Run"
408end
409
410function onSwimming(speed)
411 if (prevState ~= "Swim" and speed > 0.1) then
412 local volume = math.min(1.0, speed / 350)
413 sSplash.Volume = volume
414 sSplash:Play()
415 prevState = "Swim"
416 end
417 sClimbing:Stop()
418 sRunning:Stop()
419 sSwimming.Pitch = 1.6
420 sSwimming:Play()
421end
422
423function onClimbing(speed)
424 sRunning:Stop()
425 sSwimming:Stop()
426 if speed>0.01 then
427 sClimbing:Play()
428 sClimbing.Pitch = speed / 5.5
429 else
430 sClimbing:Stop()
431 end
432 prevState = "Climb"
433end
434-- connect up
435
436function stopLoopedSounds()
437 sRunning:Stop()
438 sClimbing:Stop()
439 sSwimming:Stop()
440end
441
442Humanoid.Died:connect(onDied)
443Humanoid.Running:connect(onRunning)
444Humanoid.Swimming:connect(onSwimming)
445Humanoid.Climbing:connect(onClimbing)
446Humanoid.Jumping:connect(function(state) onStateNoStop(state, sJumping) prevState = "Jump" end)
447Humanoid.GettingUp:connect(function(state) stopLoopedSounds() onStateNoStop(state, sGettingUp) prevState = "GetUp" end)
448Humanoid.FreeFalling:connect(function(state) stopLoopedSounds() onStateFall(state, sFreeFalling) prevState = "FreeFall" end)
449Humanoid.FallingDown:connect(function(state) stopLoopedSounds() end)
450Humanoid.StateChanged:connect(function(old, new)
451 if not (new.Name == "Dead" or
452 new.Name == "Running" or
453 new.Name == "RunningNoPhysics" or
454 new.Name == "Swimming" or
455 new.Name == "Jumping" or
456 new.Name == "GettingUp" or
457 new.Name == "Freefall" or
458 new.Name == "FallingDown") then
459 stopLoopedSounds()
460 end
461end)
462
463
464end))
465Part11.Name = "Head"
466Part11.Parent = Model0
467Part11.CFrame = CFrame.new(-40.5678635, 4.49994278, 35.5090714, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
468Part11.Orientation = Vector3.new(0, -172.380005, 0)
469Part11.Position = Vector3.new(-40.5678635, 4.49994278, 35.5090714)
470Part11.Rotation = Vector3.new(180, -7.61999989, -180)
471Part11.Color = Color3.new(0.992157, 0.917647, 0.552941)
472Part11.Size = Vector3.new(2, 1, 1)
473Part11.Anchored = true
474Part11.BrickColor = BrickColor.new("Cool yellow")
475Part11.TopSurface = Enum.SurfaceType.Smooth
476Part11.brickColor = BrickColor.new("Cool yellow")
477Part11.FormFactor = Enum.FormFactor.Symmetric
478Part11.formFactor = Enum.FormFactor.Symmetric
479SpecialMesh12.Parent = Part11
480SpecialMesh12.Scale = Vector3.new(1.25, 1.25, 1.25)
481Decal13.Name = "face"
482Decal13.Parent = Part11
483Decal13.Texture = "http://www.roblox.com/asset/?id=8560915"
484Weld14.Name = "HeadWeld"
485Weld14.Parent = Part11
486Weld14.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
487Weld14.C1 = CFrame.new(0, 0.075000003, 0.0500000007, 1, 0, 0, 0, 1, 0, 0, 0, 1)
488Weld14.Part0 = Part11
489Weld14.Part1 = Part5
490Weld14.part1 = Part5
491Part15.Name = "HumanoidRootPart"
492Part15.Parent = Model0
493Part15.CFrame = CFrame.new(-40.5678635, 3.00001192, 35.5090714, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
494Part15.Orientation = Vector3.new(0, -172.380005, 0)
495Part15.Position = Vector3.new(-40.5678635, 3.00001192, 35.5090714)
496Part15.Rotation = Vector3.new(180, -7.61999989, -180)
497Part15.Color = Color3.new(0.0509804, 0.411765, 0.67451)
498Part15.Transparency = 1
499Part15.Size = Vector3.new(2, 2, 1)
500Part15.Anchored = true
501Part15.BottomSurface = Enum.SurfaceType.Smooth
502Part15.BrickColor = BrickColor.new("Bright blue")
503Part15.CanCollide = false
504Part15.LeftParamA = 0
505Part15.LeftParamB = 0
506Part15.RightParamA = 0
507Part15.RightParamB = 0
508Part15.TopSurface = Enum.SurfaceType.Smooth
509Part15.brickColor = BrickColor.new("Bright blue")
510Part15.FormFactor = Enum.FormFactor.Symmetric
511Part15.formFactor = Enum.FormFactor.Symmetric
512Motor6D16.Name = "RootJoint"
513Motor6D16.Parent = Part15
514Motor6D16.MaxVelocity = 0.10000000149012
515Motor6D16.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
516Motor6D16.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
517Motor6D16.Part0 = Part15
518Motor6D16.Part1 = Part25
519Motor6D16.part1 = Part25
520Part17.Name = "Left Arm"
521Part17.Parent = Model0
522Part17.CFrame = CFrame.new(-39.0811081, 3.00001192, 35.3102112, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
523Part17.Orientation = Vector3.new(0, -172.380005, 0)
524Part17.Position = Vector3.new(-39.0811081, 3.00001192, 35.3102112)
525Part17.Rotation = Vector3.new(180, -7.61999989, -180)
526Part17.Color = Color3.new(0.992157, 0.917647, 0.552941)
527Part17.Size = Vector3.new(1, 2, 1)
528Part17.Anchored = true
529Part17.BrickColor = BrickColor.new("Cool yellow")
530Part17.CanCollide = false
531Part17.brickColor = BrickColor.new("Cool yellow")
532Part17.FormFactor = Enum.FormFactor.Symmetric
533Part17.formFactor = Enum.FormFactor.Symmetric
534Part18.Name = "Left Leg"
535Part18.Parent = Model0
536Part18.CFrame = CFrame.new(-40.0722809, 1.00001299, 35.4427872, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
537Part18.Orientation = Vector3.new(0, -172.380005, 0)
538Part18.Position = Vector3.new(-40.0722809, 1.00001299, 35.4427872)
539Part18.Rotation = Vector3.new(180, -7.61999989, -180)
540Part18.Color = Color3.new(0.0509804, 0.411765, 0.67451)
541Part18.Size = Vector3.new(1, 2, 1)
542Part18.Anchored = true
543Part18.BottomSurface = Enum.SurfaceType.Smooth
544Part18.BrickColor = BrickColor.new("Bright blue")
545Part18.CanCollide = false
546Part18.brickColor = BrickColor.new("Bright blue")
547Part18.FormFactor = Enum.FormFactor.Symmetric
548Part18.formFactor = Enum.FormFactor.Symmetric
549Part19.Name = "Right Arm"
550Part19.Parent = Model0
551Part19.CFrame = CFrame.new(-42.0546265, 3.00001192, 35.7079163, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
552Part19.Orientation = Vector3.new(0, -172.380005, 0)
553Part19.Position = Vector3.new(-42.0546265, 3.00001192, 35.7079163)
554Part19.Rotation = Vector3.new(180, -7.61999989, -180)
555Part19.Color = Color3.new(0.992157, 0.917647, 0.552941)
556Part19.Size = Vector3.new(1, 2, 1)
557Part19.Anchored = true
558Part19.BrickColor = BrickColor.new("Cool yellow")
559Part19.CanCollide = false
560Part19.brickColor = BrickColor.new("Cool yellow")
561Part19.FormFactor = Enum.FormFactor.Symmetric
562Part19.formFactor = Enum.FormFactor.Symmetric
563Part20.Parent = Part19
564Part20.CFrame = CFrame.new(-39.1872635, 1.20001197, 35.3598976, 0.258819014, 6.61089388e-08, -0.965925634, 7.49422995e-08, 0.999999821, 8.85217304e-08, 0.965925455, -9.52998178e-08, 0.258818984)
565Part20.Orientation = Vector3.new(0, -75, 0)
566Part20.Position = Vector3.new(-39.1872635, 1.20001197, 35.3598976)
567Part20.Rotation = Vector3.new(0, -75, 0)
568Part20.Color = Color3.new(0.737255, 0.607843, 0.364706)
569Part20.Size = Vector3.new(2, 1.60000002, 0.400000006)
570Part20.Anchored = true
571Part20.BackSurface = Enum.SurfaceType.SmoothNoOutlines
572Part20.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
573Part20.BrickColor = BrickColor.new("Cork")
574Part20.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
575Part20.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
576Part20.Material = Enum.Material.SmoothPlastic
577Part20.RightSurface = Enum.SurfaceType.SmoothNoOutlines
578Part20.TopSurface = Enum.SurfaceType.SmoothNoOutlines
579Part20.brickColor = BrickColor.new("Cork")
580Part20.FormFactor = Enum.FormFactor.Custom
581Part20.formFactor = Enum.FormFactor.Custom
582SpecialMesh21.Parent = Part20
583SpecialMesh21.MeshId = "http://www.roblox.com/asset/?id=45021509"
584SpecialMesh21.TextureId = "0"
585SpecialMesh21.MeshType = Enum.MeshType.FileMesh
586Decal22.Parent = Part20
587Decal22.Texture = "http://www.roblox.com/asset/?id=108971661"
588Script23.Name = "qPerfectionWeld"
589Script23.Parent = Part19
590table.insert(cors,sandbox(Script23,function()
591-- Created by Quenty (@Quenty, follow me on twitter).
592-- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
593-- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
594
595--[[ INSTRUCTIONS
596- Place in the model
597- Make sure model is anchored
598- That's it. It will weld the model and all children.
599
600THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
601THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
602THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
603THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
604THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
605THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
606THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
607THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
608
609This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes.
610]]
611
612--[[ DOCUMENTATION
613- Will work in tools. If ran more than once it will not create more than one weld. This is especially useful for tools that are dropped and then picked up again.
614- Will work in PBS servers
615- Will work as long as it starts out with the part anchored
616- Stores the relative CFrame as a CFrame value
617- Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
618- Utilizes a recursive algorith to find all parts in the model
619- Will reweld on script reparent if the script is initially parented to a tool.
620- Welds as fast as possible
621]]
622
623-- qPerfectionWeld.lua
624-- Created 10/6/2014
625-- Author: Quenty
626-- Version 1.0.3
627
628-- Updated 10/14/2014 - Updated to 1.0.1
629--- Bug fix with existing ROBLOX welds ? Repro by asimo3089
630
631-- Updated 10/14/2014 - Updated to 1.0.2
632--- Fixed bug fix.
633
634-- Updated 10/14/2014 - Updated to 1.0.3
635--- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
636
637local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
638
639
640local function CallOnChildren(Instance, FunctionToCall)
641 -- Calls a function on each of the children of a certain object, using recursion.
642
643 FunctionToCall(Instance)
644
645 for _, Child in next, Instance:GetChildren() do
646 CallOnChildren(Child, FunctionToCall)
647 end
648end
649
650local function GetNearestParent(Instance, ClassName)
651 -- Returns the nearest parent of a certain class, or returns nil
652
653 local Ancestor = Instance
654 repeat
655 Ancestor = Ancestor.Parent
656 if Ancestor == nil then
657 return nil
658 end
659 until Ancestor:IsA(ClassName)
660
661 return Ancestor
662end
663
664local function GetBricks(StartInstance)
665 local List = {}
666
667 -- if StartInstance:IsA("BasePart") then
668 -- List[#List+1] = StartInstance
669 -- end
670
671 CallOnChildren(StartInstance, function(Item)
672 if Item:IsA("BasePart") then
673 List[#List+1] = Item;
674 end
675 end)
676
677 return List
678end
679
680local function Modify(Instance, Values)
681 -- Modifies an Instance by using a table.
682
683 assert(type(Values) == "table", "Values is not a table");
684
685 for Index, Value in next, Values do
686 if type(Index) == "number" then
687 Value.Parent = Instance
688 else
689 Instance[Index] = Value
690 end
691 end
692 return Instance
693end
694
695local function Make(ClassType, Properties)
696 -- Using a syntax hack to create a nice way to Make new items.
697
698 return Modify(Instance.new(ClassType), Properties)
699end
700
701local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
702local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
703
704local function HasWheelJoint(Part)
705 for _, SurfaceName in pairs(Surfaces) do
706 for _, HingSurfaceName in pairs(HingSurfaces) do
707 if Part[SurfaceName].Name == HingSurfaceName then
708 return true
709 end
710 end
711 end
712
713 return false
714end
715
716local function ShouldBreakJoints(Part)
717 --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
718 -- definitely some edge cases.
719
720 if NEVER_BREAK_JOINTS then
721 return false
722 end
723
724 if HasWheelJoint(Part) then
725 return false
726 end
727
728 local Connected = Part:GetConnectedParts()
729
730 if #Connected == 1 then
731 return false
732 end
733
734 for _, Item in pairs(Connected) do
735 if HasWheelJoint(Item) then
736 return false
737 elseif not Item:IsDescendantOf(script.Parent) then
738 return false
739 end
740 end
741
742 return true
743end
744
745local function WeldTogether(Part0, Part1, JointType, WeldParent)
746 --- Weld's 2 parts together
747 -- @param Part0 The first part
748 -- @param Part1 The second part (Dependent part most of the time).
749 -- @param [JointType] The type of joint. Defaults to weld.
750 -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
751 -- @return The weld created.
752
753 JointType = JointType or "Weld"
754 local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
755
756 local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
757 Modify(NewWeld, {
758 Name = "qCFrameWeldThingy";
759 Part0 = Part0;
760 Part1 = Part1;
761 C0 = CFrame.new();--Part0.CFrame:inverse();
762 C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
763 Parent = Part1;
764 })
765
766 if not RelativeValue then
767 RelativeValue = Make("CFrameValue", {
768 Parent = Part1;
769 Name = "qRelativeCFrameWeldValue";
770 Archivable = true;
771 Value = NewWeld.C1;
772 })
773 end
774
775 return NewWeld
776end
777
778local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
779 -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
780 -- @param MainPart The part to weld the model to (can be in the model).
781 -- @param [JointType] The type of joint. Defaults to weld.
782 -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
783
784 for _, Part in pairs(Parts) do
785 if ShouldBreakJoints(Part) then
786 Part:BreakJoints()
787 end
788 end
789
790 for _, Part in pairs(Parts) do
791 if Part ~= MainPart then
792 WeldTogether(MainPart, Part, JointType, MainPart)
793 end
794 end
795
796 if not DoNotUnanchor then
797 for _, Part in pairs(Parts) do
798 Part.Anchored = false
799 end
800 MainPart.Anchored = false
801 end
802end
803
804local function PerfectionWeld()
805 local Tool = GetNearestParent(script, "Tool")
806
807 local Parts = GetBricks(script.Parent)
808 local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
809
810 if PrimaryPart then
811 WeldParts(Parts, PrimaryPart, "Weld", false)
812 else
813 warn("qWeld - Unable to weld part")
814 end
815
816 return Tool
817end
818
819local Tool = PerfectionWeld()
820
821
822if Tool and script.ClassName == "Script" then
823 --- Don't bother with local scripts
824
825 script.Parent.AncestryChanged:connect(function()
826 PerfectionWeld()
827 end)
828end
829
830-- Created by Quenty (@Quenty, follow me on twitter).
831
832end))
833Part24.Name = "Right Leg"
834Part24.Parent = Model0
835Part24.CFrame = CFrame.new(-41.0634499, 1.00001299, 35.5753479, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
836Part24.Orientation = Vector3.new(0, -172.380005, 0)
837Part24.Position = Vector3.new(-41.0634499, 1.00001299, 35.5753479)
838Part24.Rotation = Vector3.new(180, -7.61999989, -180)
839Part24.Color = Color3.new(0.0509804, 0.411765, 0.67451)
840Part24.Size = Vector3.new(1, 2, 1)
841Part24.Anchored = true
842Part24.BottomSurface = Enum.SurfaceType.Smooth
843Part24.BrickColor = BrickColor.new("Bright blue")
844Part24.CanCollide = false
845Part24.brickColor = BrickColor.new("Bright blue")
846Part24.FormFactor = Enum.FormFactor.Symmetric
847Part24.formFactor = Enum.FormFactor.Symmetric
848Part25.Name = "Torso"
849Part25.Parent = Model0
850Part25.CFrame = CFrame.new(-40.5678635, 3.00001192, 35.5090714, -0.991173744, 3.45673573e-22, -0.132566467, 4.23361882e-22, 1, -5.57848252e-22, 0.132566467, -6.09047976e-22, -0.991173744)
851Part25.Orientation = Vector3.new(0, -172.380005, 0)
852Part25.Position = Vector3.new(-40.5678635, 3.00001192, 35.5090714)
853Part25.Rotation = Vector3.new(180, -7.61999989, -180)
854Part25.Color = Color3.new(0.156863, 0.498039, 0.278431)
855Part25.Size = Vector3.new(2, 2, 1)
856Part25.Anchored = true
857Part25.BrickColor = BrickColor.new("Dark green")
858Part25.LeftParamA = 0
859Part25.LeftParamB = 0
860Part25.LeftSurface = Enum.SurfaceType.Weld
861Part25.RightParamA = 0
862Part25.RightParamB = 0
863Part25.RightSurface = Enum.SurfaceType.Weld
864Part25.brickColor = BrickColor.new("Dark green")
865Part25.FormFactor = Enum.FormFactor.Symmetric
866Part25.formFactor = Enum.FormFactor.Symmetric
867Decal26.Name = "roblox"
868Decal26.Parent = Part25
869Motor6D27.Name = "Right Shoulder"
870Motor6D27.Parent = Part25
871Motor6D27.MaxVelocity = 0.10000000149012
872Motor6D27.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
873Motor6D27.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
874Motor6D27.Part0 = Part25
875Motor6D27.Part1 = Part19
876Motor6D27.part1 = Part19
877Motor6D28.Name = "Left Shoulder"
878Motor6D28.Parent = Part25
879Motor6D28.MaxVelocity = 0.10000000149012
880Motor6D28.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
881Motor6D28.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
882Motor6D28.Part0 = Part25
883Motor6D28.Part1 = Part17
884Motor6D28.part1 = Part17
885Motor6D29.Name = "Right Hip"
886Motor6D29.Parent = Part25
887Motor6D29.MaxVelocity = 0.10000000149012
888Motor6D29.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
889Motor6D29.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
890Motor6D29.Part0 = Part25
891Motor6D29.Part1 = Part24
892Motor6D29.part1 = Part24
893Motor6D30.Name = "Left Hip"
894Motor6D30.Parent = Part25
895Motor6D30.MaxVelocity = 0.10000000149012
896Motor6D30.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
897Motor6D30.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
898Motor6D30.Part0 = Part25
899Motor6D30.Part1 = Part18
900Motor6D30.part1 = Part18
901Motor6D31.Name = "Neck"
902Motor6D31.Parent = Part25
903Motor6D31.MaxVelocity = 0.10000000149012
904Motor6D31.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
905Motor6D31.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
906Motor6D31.Part0 = Part25
907Motor6D31.Part1 = Part11
908Motor6D31.part1 = Part11
909Script32.Name = "Move"
910Script32.Parent = Model0
911table.insert(cors,sandbox(Script32,function()
912local CurrentPart = nil
913local MaxInc = 16
914
915function onTouched(hit)
916 if hit.Parent == nil then
917 return
918 end
919
920 local humanoid = hit.Parent:findFirstChild("Humanoid")
921
922 if humanoid == nil then
923 CurrentPart = hit
924 end
925end
926
927function waitForChild(parent, childName)
928 local child = parent:findFirstChild(childName)
929
930 if child then
931 return child
932 end
933
934 while true do
935 print(childName)
936
937 child = parent.ChildAdded:wait()
938
939 if child.Name==childName then
940 return child
941 end
942 end
943end
944
945local Figure = script.Parent
946local Humanoid = waitForChild(Figure, "Humanoid")
947local Torso = waitForChild(Figure, "Torso")
948local Left = waitForChild(Figure, "Left Leg")
949local Right = waitForChild(Figure, "Right Leg")
950
951Humanoid.Jump = true
952
953Left.Touched:connect(onTouched)
954Right.Touched:connect(onTouched)
955
956while true do
957 wait(math.random(2, 10))
958
959 if CurrentPart ~= nil then
960 if math.random(1, 2) == 1 then
961 Humanoid.Jump = true
962 end
963
964 Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
965 end
966end
967end))
968Script33.Name = "Animate"
969Script33.Parent = Model0
970table.insert(cors,sandbox(Script33,function()
971function waitForChild(parent, childName)
972local child = parent:findFirstChild(childName)
973if child then return child end
974while true do
975child = parent.ChildAdded:wait()
976if child.Name==childName then return child end
977end
978end
979local Figure = script.Parent
980local Torso = waitForChild(Figure, "Torso")
981local RightShoulder = waitForChild(Torso, "Right Shoulder")
982local LeftShoulder = waitForChild(Torso, "Left Shoulder")
983local RightHip = waitForChild(Torso, "Right Hip")
984local LeftHip = waitForChild(Torso, "Left Hip")
985local Neck = waitForChild(Torso, "Neck")
986local Humanoid;
987for _,Child in pairs(Figure:GetChildren())do
988if Child and Child.ClassName=="Humanoid"then
989Humanoid=Child;
990end;
991end;
992local pose = "Standing"
993local currentAnim = ""
994local currentAnimInstance = nil
995local currentAnimTrack = nil
996local currentAnimKeyframeHandler = nil
997local currentAnimSpeed = 1.0
998local animTable = {}
999local animNames = {
1000idle = {
1001{ id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
1002{ id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
1003},
1004walk = {
1005{ id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
1006},
1007run = {
1008{ id = "run.xml", weight = 10 }
1009},
1010jump = {
1011{ id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
1012},
1013fall = {
1014{ id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
1015},
1016climb = {
1017{ id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
1018},
1019sit = {
1020{ id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
1021},
1022toolnone = {
1023{ id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
1024},
1025toolslash = {
1026{ id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
1027--{ id = "slash.xml", weight = 10 }
1028},
1029toollunge = {
1030{ id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
1031},
1032wave = {
1033{ id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
1034},
1035point = {
1036{ id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
1037},
1038dance1 = {
1039{ id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
1040{ id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
1041{ id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
1042},
1043dance2 = {
1044{ id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
1045{ id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
1046{ id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
1047},
1048dance3 = {
1049{ id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
1050{ id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
1051{ id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
1052},
1053laugh = {
1054{ id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
1055},
1056cheer = {
1057{ id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
1058},
1059}
1060local dances = {"dance1", "dance2", "dance3"}
1061
1062-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
1063local emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
1064
1065function configureAnimationSet(name, fileList)
1066if (animTable[name] ~= nil) then
1067for _, connection in pairs(animTable[name].connections) do
1068connection:disconnect()
1069end
1070end
1071animTable[name] = {}
1072animTable[name].count = 0
1073animTable[name].totalWeight = 0
1074animTable[name].connections = {}
1075
1076-- check for config values
1077local config = script:FindFirstChild(name)
1078if (config ~= nil) then
1079--print("Loading anims " .. name)
1080table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
1081table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
1082local idx = 1
1083for _, childPart in pairs(config:GetChildren()) do
1084if (childPart:IsA("Animation")) then
1085table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
1086animTable[name][idx] = {}
1087animTable[name][idx].anim = childPart
1088local weightObject = childPart:FindFirstChild("Weight")
1089if (weightObject == nil) then
1090animTable[name][idx].weight = 1
1091else
1092animTable[name][idx].weight = weightObject.Value
1093end
1094animTable[name].count = animTable[name].count + 1
1095animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
1096--print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
1097idx = idx + 1
1098end
1099end
1100end
1101
1102-- fallback to defaults
1103if (animTable[name].count <= 0) then
1104for idx, anim in pairs(fileList) do
1105animTable[name][idx] = {}
1106animTable[name][idx].anim = Instance.new("Animation")
1107animTable[name][idx].anim.Name = name
1108animTable[name][idx].anim.AnimationId = anim.id
1109animTable[name][idx].weight = anim.weight
1110animTable[name].count = animTable[name].count + 1
1111animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
1112--print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
1113end
1114end
1115end
1116
1117-- Setup animation objects
1118function scriptChildModified(child)
1119local fileList = animNames[child.Name]
1120if (fileList ~= nil) then
1121configureAnimationSet(child.Name, fileList)
1122end
1123end
1124
1125script.ChildAdded:connect(scriptChildModified)
1126script.ChildRemoved:connect(scriptChildModified)
1127
1128
1129for name, fileList in pairs(animNames) do
1130configureAnimationSet(name, fileList)
1131end
1132
1133-- ANIMATION
1134
1135-- declarations
1136local toolAnim = "None"
1137local toolAnimTime = 0
1138
1139local jumpAnimTime = 0
1140local jumpAnimDuration = 0.3
1141
1142local toolTransitionTime = 0.1
1143local fallTransitionTime = 0.3
1144local jumpMaxLimbVelocity = 0.75
1145
1146-- functions
1147
1148function stopAllAnimations()
1149local oldAnim = currentAnim
1150
1151-- return to idle if finishing an emote
1152if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
1153oldAnim = "idle"
1154end
1155
1156currentAnim = ""
1157currentAnimInstance = nil
1158if (currentAnimKeyframeHandler ~= nil) then
1159currentAnimKeyframeHandler:disconnect()
1160end
1161
1162if (currentAnimTrack ~= nil) then
1163currentAnimTrack:Stop()
1164currentAnimTrack:Destroy()
1165currentAnimTrack = nil
1166end
1167return oldAnim
1168end
1169
1170function setAnimationSpeed(speed)
1171if speed ~= currentAnimSpeed then
1172currentAnimSpeed = speed
1173currentAnimTrack:AdjustSpeed(currentAnimSpeed)
1174end
1175end
1176
1177function keyFrameReachedFunc(frameName)
1178if (frameName == "End") then
1179
1180local repeatAnim = currentAnim
1181-- return to idle if finishing an emote
1182if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
1183repeatAnim = "idle"
1184end
1185
1186local animSpeed = currentAnimSpeed
1187playAnimation(repeatAnim, 0.0, Humanoid)
1188setAnimationSpeed(animSpeed)
1189end
1190end
1191
1192-- Preload animations
1193function playAnimation(animName, transitionTime, humanoid)
1194
1195local roll = math.random(1, animTable[animName].totalWeight)
1196local origRoll = roll
1197local idx = 1
1198while (roll > animTable[animName][idx].weight) do
1199roll = roll - animTable[animName][idx].weight
1200idx = idx + 1
1201end
1202--print(animName .. " " .. idx .. " [" .. origRoll .. "]")
1203local anim = animTable[animName][idx].anim
1204-- switch animation
1205if (anim ~= currentAnimInstance) then
1206if (currentAnimTrack ~= nil) then
1207currentAnimTrack:Stop(transitionTime)
1208currentAnimTrack:Destroy()
1209end
1210currentAnimSpeed = 1.0
1211-- load it to the humanoid; get AnimationTrack
1212currentAnimTrack = humanoid:LoadAnimation(anim)
1213-- play the animation
1214currentAnimTrack:Play(transitionTime)
1215currentAnim = animName
1216currentAnimInstance = anim
1217-- set up keyframe name triggers
1218if (currentAnimKeyframeHandler ~= nil) then
1219currentAnimKeyframeHandler:disconnect()
1220end
1221currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
1222end
1223end
1224-------------------------------------------------------------------------------------------
1225-------------------------------------------------------------------------------------------
1226local toolAnimName = ""
1227local toolAnimTrack = nil
1228local toolAnimInstance = nil
1229local currentToolAnimKeyframeHandler = nil
1230function toolKeyFrameReachedFunc(frameName)
1231if (frameName == "End") then
1232--print("Keyframe : ".. frameName)
1233playToolAnimation(toolAnimName, 0.0, Humanoid)
1234end
1235end
1236function playToolAnimation(animName, transitionTime, humanoid)
1237local roll = math.random(1, animTable[animName].totalWeight)
1238local origRoll = roll
1239local idx = 1
1240while (roll > animTable[animName][idx].weight) do
1241roll = roll - animTable[animName][idx].weight
1242idx = idx + 1
1243end
1244--print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
1245local anim = animTable[animName][idx].anim
1246if (toolAnimInstance ~= anim) then
1247if (toolAnimTrack ~= nil) then
1248toolAnimTrack:Stop()
1249toolAnimTrack:Destroy()
1250transitionTime = 0
1251end
1252-- load it to the humanoid; get AnimationTrack
1253toolAnimTrack = humanoid:LoadAnimation(anim)
1254-- play the animation
1255toolAnimTrack:Play(transitionTime)
1256toolAnimName = animName
1257toolAnimInstance = anim
1258currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
1259end
1260end
1261function stopToolAnimations()
1262local oldAnim = toolAnimName
1263if (currentToolAnimKeyframeHandler ~= nil) then
1264currentToolAnimKeyframeHandler:disconnect()
1265end
1266toolAnimName = ""
1267toolAnimInstance = nil
1268if (toolAnimTrack ~= nil) then
1269toolAnimTrack:Stop()
1270toolAnimTrack:Destroy()
1271toolAnimTrack = nil
1272end
1273return oldAnim
1274end
1275-------------------------------------------------------------------------------------------
1276-------------------------------------------------------------------------------------------
1277function onRunning(speed)
1278if speed>0.01 then
1279playAnimation("walk", 0.1, Humanoid)
1280if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
1281setAnimationSpeed(speed / 14.5)
1282end
1283pose = "Running"
1284else
1285playAnimation("idle", 0.1, Humanoid)
1286pose = "Standing"
1287end
1288end
1289function onDied()
1290pose = "Dead"
1291end
1292function onJumping()
1293playAnimation("jump", 0.1, Humanoid)
1294jumpAnimTime = jumpAnimDuration
1295pose = "Jumping"
1296end
1297function onClimbing(speed)
1298playAnimation("climb", 0.1, Humanoid)
1299setAnimationSpeed(speed / 12.0)
1300pose = "Climbing"
1301end
1302function onGettingUp()
1303pose = "GettingUp"
1304end
1305function onFreeFall()
1306if (jumpAnimTime <= 0) then
1307playAnimation("fall", fallTransitionTime, Humanoid)
1308end
1309pose = "FreeFall"
1310end
1311function onFallingDown()
1312pose = "FallingDown"
1313end
1314function onSeated()
1315pose = "Seated"
1316end
1317function onPlatformStanding()
1318pose = "PlatformStanding"
1319end
1320function onSwimming(speed)
1321if speed>0 then
1322pose = "Running"
1323else
1324pose = "Standing"
1325end
1326end
1327
1328function getTool()
1329for _, kid in ipairs(Figure:GetChildren()) do
1330if kid.className == "Tool" then return kid end
1331end
1332return nil
1333end
1334
1335function getToolAnim(tool)
1336for _, c in ipairs(tool:GetChildren()) do
1337if c.Name == "toolanim" and c.className == "StringValue" then
1338return c
1339end
1340end
1341return nil
1342end
1343
1344function animateTool()
1345
1346if (toolAnim == "None") then
1347playToolAnimation("toolnone", toolTransitionTime, Humanoid)
1348return
1349end
1350
1351if (toolAnim == "Slash") then
1352playToolAnimation("toolslash", 0, Humanoid)
1353return
1354end
1355
1356if (toolAnim == "Lunge") then
1357playToolAnimation("toollunge", 0, Humanoid)
1358return
1359end
1360end
1361
1362function moveSit()
1363RightShoulder.MaxVelocity = 0.15
1364LeftShoulder.MaxVelocity = 0.15
1365RightShoulder:SetDesiredAngle(3.14 /2)
1366LeftShoulder:SetDesiredAngle(-3.14 /2)
1367RightHip:SetDesiredAngle(3.14 /2)
1368LeftHip:SetDesiredAngle(-3.14 /2)
1369end
1370
1371local lastTick = 0
1372
1373function move(time)
1374local amplitude = 1
1375local frequency = 1
1376 local deltaTime = time - lastTick
1377 lastTick = time
1378
1379local climbFudge = 0
1380local setAngles = false
1381
1382 if (jumpAnimTime > 0) then
1383 jumpAnimTime = jumpAnimTime - deltaTime
1384 end
1385
1386if (pose == "FreeFall" and jumpAnimTime <= 0) then
1387playAnimation("fall", fallTransitionTime, Humanoid)
1388elseif (pose == "Seated") then
1389playAnimation("sit", 0.5, Humanoid)
1390return
1391elseif (pose == "Running") then
1392playAnimation("walk", 0.1, Humanoid)
1393elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
1394stopAllAnimations()
1395amplitude = 0.1
1396frequency = 1
1397setAngles = true
1398end
1399if (setAngles) then
1400local desiredAngle = amplitude * math.sin(time * frequency)
1401RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
1402LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
1403RightHip:SetDesiredAngle(-desiredAngle)
1404LeftHip:SetDesiredAngle(-desiredAngle)
1405end
1406-- Tool Animation handling
1407local tool = getTool()
1408if tool and tool:FindFirstChild("Handle") then
1409local animStringValueObject = getToolAnim(tool)
1410if animStringValueObject then
1411toolAnim = animStringValueObject.Value
1412-- message recieved, delete StringValue
1413animStringValueObject.Parent = nil
1414toolAnimTime = time + .3
1415end
1416if time > toolAnimTime then
1417toolAnimTime = 0
1418toolAnim = "None"
1419end
1420animateTool()
1421else
1422stopToolAnimations()
1423toolAnim = "None"
1424toolAnimInstance = nil
1425toolAnimTime = 0
1426end
1427end
1428-- connect events
1429Humanoid.Died:connect(onDied)
1430Humanoid.Running:connect(onRunning)
1431Humanoid.Jumping:connect(onJumping)
1432Humanoid.Climbing:connect(onClimbing)
1433Humanoid.GettingUp:connect(onGettingUp)
1434Humanoid.FreeFalling:connect(onFreeFall)
1435Humanoid.FallingDown:connect(onFallingDown)
1436Humanoid.Seated:connect(onSeated)
1437Humanoid.PlatformStanding:connect(onPlatformStanding)
1438Humanoid.Swimming:connect(onSwimming)
1439local runService = game:GetService("RunService");
1440playAnimation("idle", 0.1, Humanoid)
1441pose = "Standing"
1442while Wait(0)do
1443local _,time=wait(0)
1444move(time)
1445end
1446end))
1447StringValue34.Name = "climb"
1448StringValue34.Parent = Script33
1449Animation35.Name = "ClimbAnim"
1450Animation35.Parent = StringValue34
1451Animation35.AnimationId = "http://www.roblox.com/asset/?id=180436334"
1452StringValue36.Name = "fall"
1453StringValue36.Parent = Script33
1454Animation37.Name = "FallAnim"
1455Animation37.Parent = StringValue36
1456Animation37.AnimationId = "http://www.roblox.com/asset/?id=180436148"
1457StringValue38.Name = "idle"
1458StringValue38.Parent = Script33
1459Animation39.Name = "Animation1"
1460Animation39.Parent = StringValue38
1461Animation39.AnimationId = "http://www.roblox.com/asset/?id=180435571"
1462NumberValue40.Name = "Weight"
1463NumberValue40.Parent = Animation39
1464NumberValue40.Value = 9
1465Animation41.Name = "Animation2"
1466Animation41.Parent = StringValue38
1467Animation41.AnimationId = "http://www.roblox.com/asset/?id=180435792"
1468NumberValue42.Name = "Weight"
1469NumberValue42.Parent = Animation41
1470NumberValue42.Value = 1
1471StringValue43.Name = "jump"
1472StringValue43.Parent = Script33
1473Animation44.Name = "JumpAnim"
1474Animation44.Parent = StringValue43
1475Animation44.AnimationId = "http://www.roblox.com/asset/?id=125750702"
1476StringValue45.Name = "run"
1477StringValue45.Parent = Script33
1478Animation46.Name = "RunAnim"
1479Animation46.Parent = StringValue45
1480Animation46.AnimationId = "http://www.roblox.com/asset/?id=180426354"
1481StringValue47.Name = "sit"
1482StringValue47.Parent = Script33
1483Animation48.Name = "SitAnim"
1484Animation48.Parent = StringValue47
1485Animation48.AnimationId = "http://www.roblox.com/asset/?id=178130996"
1486StringValue49.Name = "toolnone"
1487StringValue49.Parent = Script33
1488Animation50.Name = "ToolNoneAnim"
1489Animation50.Parent = StringValue49
1490Animation50.AnimationId = "http://www.roblox.com/asset/?id=182393478"
1491StringValue51.Name = "walk"
1492StringValue51.Parent = Script33
1493Animation52.Name = "WalkAnim"
1494Animation52.Parent = StringValue51
1495Animation52.AnimationId = "http://www.roblox.com/asset/?id=180426354"
1496for i,v in pairs(mas:GetChildren()) do
1497 v.Parent = workspace
1498 pcall(function() v:MakeJoints() end)
1499end
1500mas:Destroy()
1501for i,v in pairs(cors) do
1502 spawn(function()
1503 pcall(v)
1504 end)
1505end