sawgamer1

Untitled

Dec 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.14 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function 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
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Model0 = Instance.new("Model")
  20. Part1 = Instance.new("Part")
  21. Weld2 = Instance.new("Weld")
  22. SpecialMesh3 = Instance.new("SpecialMesh")
  23. Decal4 = Instance.new("Decal")
  24. Sound5 = Instance.new("Sound")
  25. Part6 = Instance.new("Part")
  26. Decal7 = Instance.new("Decal")
  27. Motor6D8 = Instance.new("Motor6D")
  28. Motor6D9 = Instance.new("Motor6D")
  29. Motor6D10 = Instance.new("Motor6D")
  30. Motor6D11 = Instance.new("Motor6D")
  31. Motor6D12 = Instance.new("Motor6D")
  32. Part13 = Instance.new("Part")
  33. Part14 = Instance.new("Part")
  34. Part15 = Instance.new("Part")
  35. Script16 = Instance.new("Script")
  36. Part17 = Instance.new("Part")
  37. Script18 = Instance.new("Script")
  38. BoolValue19 = Instance.new("BoolValue")
  39. Script20 = Instance.new("Script")
  40. BoolValue21 = Instance.new("BoolValue")
  41. Humanoid22 = Instance.new("Humanoid")
  42. ObjectValue23 = Instance.new("ObjectValue")
  43. Script24 = Instance.new("Script")
  44. Script25 = Instance.new("Script")
  45. Script26 = Instance.new("Script")
  46. NumberValue27 = Instance.new("NumberValue")
  47. ObjectValue28 = Instance.new("ObjectValue")
  48. Animation29 = Instance.new("Animation")
  49. Script30 = Instance.new("Script")
  50. StringValue31 = Instance.new("StringValue")
  51. Animation32 = Instance.new("Animation")
  52. StringValue33 = Instance.new("StringValue")
  53. Animation34 = Instance.new("Animation")
  54. StringValue35 = Instance.new("StringValue")
  55. Animation36 = Instance.new("Animation")
  56. NumberValue37 = Instance.new("NumberValue")
  57. Animation38 = Instance.new("Animation")
  58. NumberValue39 = Instance.new("NumberValue")
  59. StringValue40 = Instance.new("StringValue")
  60. Animation41 = Instance.new("Animation")
  61. StringValue42 = Instance.new("StringValue")
  62. Animation43 = Instance.new("Animation")
  63. StringValue44 = Instance.new("StringValue")
  64. Animation45 = Instance.new("Animation")
  65. StringValue46 = Instance.new("StringValue")
  66. Animation47 = Instance.new("Animation")
  67. StringValue48 = Instance.new("StringValue")
  68. Animation49 = Instance.new("Animation")
  69. Camera50 = Instance.new("Camera")
  70. Pants51 = Instance.new("Pants")
  71. Shirt52 = Instance.new("Shirt")
  72. Folder53 = Instance.new("Folder")
  73. Sound54 = Instance.new("Sound")
  74. Script55 = Instance.new("Script")
  75. Script56 = Instance.new("Script")
  76. LocalScript57 = Instance.new("LocalScript")
  77. ScreenGui58 = Instance.new("ScreenGui")
  78. TextButton59 = Instance.new("TextButton")
  79. ModuleScript60 = Instance.new("ModuleScript")
  80. Model0.Name = "Zombie Yeti"
  81. Model0.Parent = mas
  82. Part1.Name = "Head"
  83. Part1.Parent = Model0
  84. Part1.CFrame = CFrame.new(-6.13871002, 9.14999771, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  85. Part1.Orientation = Vector3.new(0, -180, 0)
  86. Part1.Position = Vector3.new(-6.13871002, 9.14999771, -11.4352522)
  87. Part1.Rotation = Vector3.new(-180, 0, -180)
  88. Part1.Color = Color3.new(0.94902, 0.952941, 0.952941)
  89. Part1.Size = Vector3.new(4, 2, 2)
  90. Part1.BrickColor = BrickColor.new("White")
  91. Part1.TopSurface = Enum.SurfaceType.Smooth
  92. Part1.brickColor = BrickColor.new("White")
  93. Part1.FormFactor = Enum.FormFactor.Symmetric
  94. Part1.formFactor = Enum.FormFactor.Symmetric
  95. Weld2.Name = "HeadWeld"
  96. Weld2.Parent = Part1
  97. Weld2.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  98. Weld2.C1 = CFrame.new(0, 0.25, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  99. SpecialMesh3.Parent = Part1
  100. SpecialMesh3.Scale = Vector3.new(1.25, 1.25, 1.25)
  101. Decal4.Name = "Papyrus Face"
  102. Decal4.Parent = Part1
  103. Decal4.Texture = "http://www.roblox.com/asset/?id=785118827"
  104. Sound5.Name = "Undertale - Genocide Papyrus [Backbone]"
  105. Sound5.Parent = Part1
  106. Sound5.SoundId = "rbxassetid://321451733"
  107. Part6.Name = "Torso"
  108. Part6.Parent = Model0
  109. Part6.CFrame = CFrame.new(-6.13871002, 5.99999809, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  110. Part6.Orientation = Vector3.new(0, -180, 0)
  111. Part6.Position = Vector3.new(-6.13871002, 5.99999809, -11.4352522)
  112. Part6.Rotation = Vector3.new(-180, 0, -180)
  113. Part6.Color = Color3.new(0.94902, 0.952941, 0.952941)
  114. Part6.Size = Vector3.new(4, 4, 2)
  115. Part6.BrickColor = BrickColor.new("White")
  116. Part6.LeftParamA = 0
  117. Part6.LeftParamB = 0
  118. Part6.LeftSurface = Enum.SurfaceType.Weld
  119. Part6.Material = Enum.Material.Ice
  120. Part6.RightParamA = 0
  121. Part6.RightParamB = 0
  122. Part6.RightSurface = Enum.SurfaceType.Weld
  123. Part6.brickColor = BrickColor.new("White")
  124. Part6.FormFactor = Enum.FormFactor.Symmetric
  125. Part6.formFactor = Enum.FormFactor.Symmetric
  126. Decal7.Name = "roblox"
  127. Decal7.Parent = Part6
  128. Motor6D8.Name = "Right Shoulder"
  129. Motor6D8.Parent = Part6
  130. Motor6D8.MaxVelocity = 0.15000000596046
  131. Motor6D8.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  132. Motor6D8.C1 = CFrame.new(-2, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  133. Motor6D8.Part0 = Part6
  134. Motor6D8.Part1 = Part14
  135. Motor6D8.part1 = Part14
  136. Motor6D9.Name = "Left Shoulder"
  137. Motor6D9.Parent = Part6
  138. Motor6D9.MaxVelocity = 0.15000000596046
  139. Motor6D9.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  140. Motor6D9.C1 = CFrame.new(1.99999976, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  141. Motor6D9.Part0 = Part6
  142. Motor6D9.Part1 = Part13
  143. Motor6D9.part1 = Part13
  144. Motor6D10.Name = "Right Hip"
  145. Motor6D10.Parent = Part6
  146. Motor6D10.MaxVelocity = 0.10000000149012
  147. Motor6D10.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  148. Motor6D10.C1 = CFrame.new(0, 3, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  149. Motor6D10.Part0 = Part6
  150. Motor6D10.Part1 = Part17
  151. Motor6D10.part1 = Part17
  152. Motor6D11.Name = "Left Hip"
  153. Motor6D11.Parent = Part6
  154. Motor6D11.MaxVelocity = 0.10000000149012
  155. Motor6D11.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  156. Motor6D11.C1 = CFrame.new(0, 3, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  157. Motor6D11.Part0 = Part6
  158. Motor6D11.Part1 = Part15
  159. Motor6D11.part1 = Part15
  160. Motor6D12.Name = "Neck"
  161. Motor6D12.Parent = Part6
  162. Motor6D12.C1 = CFrame.new(0, 3.1500001, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  163. Motor6D12.Part0 = Part1
  164. Motor6D12.Part1 = Part6
  165. Motor6D12.part1 = Part6
  166. Part13.Name = "Left Arm"
  167. Part13.Parent = Model0
  168. Part13.CFrame = CFrame.new(-3.13871074, 5.99999809, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  169. Part13.Orientation = Vector3.new(0, -180, 0)
  170. Part13.Position = Vector3.new(-3.13871074, 5.99999809, -11.4352522)
  171. Part13.Rotation = Vector3.new(-180, 0, -180)
  172. Part13.Color = Color3.new(0.94902, 0.952941, 0.952941)
  173. Part13.Size = Vector3.new(2, 4, 2)
  174. Part13.BottomSurface = Enum.SurfaceType.Smooth
  175. Part13.BrickColor = BrickColor.new("White")
  176. Part13.CanCollide = false
  177. Part13.Material = Enum.Material.Ice
  178. Part13.brickColor = BrickColor.new("White")
  179. Part13.FormFactor = Enum.FormFactor.Symmetric
  180. Part13.formFactor = Enum.FormFactor.Symmetric
  181. Part14.Name = "Right Arm"
  182. Part14.Parent = Model0
  183. Part14.CFrame = CFrame.new(-9.13871002, 5.99999809, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  184. Part14.Orientation = Vector3.new(0, -180, 0)
  185. Part14.Position = Vector3.new(-9.13871002, 5.99999809, -11.4352522)
  186. Part14.Rotation = Vector3.new(-180, 0, -180)
  187. Part14.Color = Color3.new(0.94902, 0.952941, 0.952941)
  188. Part14.Size = Vector3.new(2, 4, 2)
  189. Part14.BottomSurface = Enum.SurfaceType.Smooth
  190. Part14.BrickColor = BrickColor.new("White")
  191. Part14.CanCollide = false
  192. Part14.Material = Enum.Material.Ice
  193. Part14.brickColor = BrickColor.new("White")
  194. Part14.FormFactor = Enum.FormFactor.Symmetric
  195. Part14.formFactor = Enum.FormFactor.Symmetric
  196. Part15.Name = "Left Leg"
  197. Part15.Parent = Model0
  198. Part15.CFrame = CFrame.new(-5.13871002, 1.99999809, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  199. Part15.Orientation = Vector3.new(0, -180, 0)
  200. Part15.Position = Vector3.new(-5.13871002, 1.99999809, -11.4352522)
  201. Part15.Rotation = Vector3.new(-180, 0, -180)
  202. Part15.Color = Color3.new(0.94902, 0.952941, 0.952941)
  203. Part15.Size = Vector3.new(2, 4, 2)
  204. Part15.BottomSurface = Enum.SurfaceType.Smooth
  205. Part15.BrickColor = BrickColor.new("White")
  206. Part15.CanCollide = false
  207. Part15.Material = Enum.Material.Ice
  208. Part15.brickColor = BrickColor.new("White")
  209. Part15.FormFactor = Enum.FormFactor.Symmetric
  210. Part15.formFactor = Enum.FormFactor.Symmetric
  211. Script16.Parent = Part15
  212. table.insert(cors,sandbox(Script16,function()
  213. function touch(hit)
  214. if hit.Parent.Name == "Tank" or hit.Parent.Name == "Brotherhood Of Scythe" then
  215. script.Parent.Parent.Humanoid.Jump = true
  216. end
  217. end
  218.  
  219. script.Parent.Touched:connect(touch)
  220.  
  221. while true do
  222. touch = script.Parent:findFirstChild("TouchInterest")
  223. if touch == nil then
  224. script.Parent.Touched:connect(touch)
  225. end
  226. wait()
  227. end
  228.  
  229. end))
  230. Part17.Name = "Right Leg"
  231. Part17.Parent = Model0
  232. Part17.CFrame = CFrame.new(-7.13871002, 1.99999809, -11.4352522, -0.999999821, 1.33315838e-08, -2.98023224e-08, 1.33315865e-08, 1, 4.03998524e-09, 2.98023224e-08, 4.03997991e-09, -0.999999821)
  233. Part17.Orientation = Vector3.new(0, -180, 0)
  234. Part17.Position = Vector3.new(-7.13871002, 1.99999809, -11.4352522)
  235. Part17.Rotation = Vector3.new(-180, 0, -180)
  236. Part17.Color = Color3.new(0.94902, 0.952941, 0.952941)
  237. Part17.Size = Vector3.new(2, 4, 2)
  238. Part17.BottomSurface = Enum.SurfaceType.Smooth
  239. Part17.BrickColor = BrickColor.new("White")
  240. Part17.CanCollide = false
  241. Part17.Material = Enum.Material.Ice
  242. Part17.brickColor = BrickColor.new("White")
  243. Part17.FormFactor = Enum.FormFactor.Symmetric
  244. Part17.formFactor = Enum.FormFactor.Symmetric
  245. Script18.Parent = Part17
  246. table.insert(cors,sandbox(Script18,function()
  247. function touch(hit)
  248. if hit.Parent.Name == "Tank" or hit.Parent.Name == "Brotherhood Of Scythe" then
  249. script.Parent.Parent.Humanoid.Jump = true
  250. end
  251. end
  252.  
  253. script.Parent.Touched:connect(touch)
  254.  
  255. while true do
  256. touch = script.Parent:findFirstChild("TouchInterest")
  257. if touch == nil then
  258. script.Parent.Touched:connect(touch)
  259. end
  260. wait()
  261. end
  262.  
  263. end))
  264. BoolValue19.Name = "Attack"
  265. BoolValue19.Parent = Model0
  266. Script20.Name = "ChaseScript"
  267. Script20.Parent = Model0
  268. table.insert(cors,sandbox(Script20,function()
  269. wait()
  270. zombieParent = false
  271.  
  272. while zombieParent == false do
  273.  
  274. wait()
  275. if script.Parent.Name == "Zombie Yeti" then
  276. zombieParent = true
  277. end
  278.  
  279. end
  280.  
  281. local larm = script.Parent:FindFirstChild("Left Arm")
  282. local rarm = script.Parent:FindFirstChild("Right Arm")
  283. local waitTimer = 0
  284.  
  285. function findNearestTorso(pos)
  286. local list = game.Workspace:children()
  287. local torso = nil
  288. local dist = 10000
  289. local temp = nil
  290. local human = nil
  291. local temp2 = nil
  292. for x = 1, #list do
  293. temp2 = list[x]
  294. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  295. temp = temp2:findFirstChild("Torso")
  296. human = temp2:findFirstChild("Humanoid")
  297. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  298. if (temp.Position - pos).magnitude < dist then
  299. torso = temp
  300. script.Parent.Target.Value = temp
  301. dist = (temp.Position - pos).magnitude
  302.  
  303. if human.Health >= 1 then
  304. script.Parent.Range.Value = true
  305. else
  306. script.Parent.Range.Value = false
  307. end
  308. end
  309. end
  310. if dist < 10 then
  311. script.Parent.Attack.Value = true
  312. else
  313. script.Parent.Attack.Value = false
  314. end
  315. end
  316. end
  317. return torso
  318. end
  319.  
  320. function Sit()
  321. if script.Parent.Zombie.Sit == true then
  322. script.Parent.Zombie.Jump = true
  323. print("Anti Seat Putter!!!")
  324. end
  325. end
  326.  
  327. script.Parent.Zombie.Changed:connect(Sit)
  328.  
  329. function touch(hit)
  330. if hit and hit.Parent then
  331. if hit.Parent.Name == "Ballista" or hit.Parent.Name == "Brotherhood Of Scythe" or hit.Parent.Name == "Jump" then
  332. script.Parent.Zombie.Jump = true
  333. end
  334. end
  335. end
  336.  
  337. script.Parent["Right Leg"].Touched:connect(touch)
  338.  
  339. script.Parent["Left Leg"].Touched:connect(touch)
  340.  
  341. while true do
  342. wait(1)
  343. local target = findNearestTorso(script.Parent.Torso.Position)
  344. if target ~= nil then
  345. rx = math.random(-3,3)
  346. ry = math.random(0,0)
  347. rz = math.random(-3,3)
  348. script.Parent.Zombie:MoveTo(target.Position+Vector3.new(rx,ry,rz), target)
  349. else
  350. script.Parent.Range.Value = false
  351. script.Parent.Attack.Value = false
  352. end
  353. end
  354.  
  355. end))
  356. BoolValue21.Name = "Range"
  357. BoolValue21.Parent = Model0
  358. Humanoid22.Name = "Zombie"
  359. Humanoid22.Parent = Model0
  360. Humanoid22.Health = 4752
  361. Humanoid22.LeftLeg = Part15
  362. Humanoid22.MaxHealth = 4752
  363. Humanoid22.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  364. Humanoid22.RightLeg = Part17
  365. Humanoid22.Torso = Part6
  366. Humanoid22.WalkSpeed = 75
  367. Humanoid22.maxHealth = 4752
  368. ObjectValue23.Name = "Target"
  369. ObjectValue23.Parent = Model0
  370. Script24.Name = "Die"
  371. Script24.Parent = Model0
  372. table.insert(cors,sandbox(Script24,function()
  373. human = script.Parent.Zombie
  374. --tool = script.Parent.Pistol
  375.  
  376. function Die()
  377. --if tool ~= nil then tool:remove() end
  378. wait(2.5)
  379. script.Parent:remove()
  380. end
  381.  
  382. human.Died:connect(Die)
  383. end))
  384. Script25.Name = "ZombieScript"
  385. Script25.Parent = Model0
  386. table.insert(cors,sandbox(Script25,function()
  387. wait(1.5)
  388. local sp = script.Parent
  389. local Humanoid = sp:WaitForChild("Zombie")
  390. local Head = sp:WaitForChild("Head")
  391. local Torso = sp:WaitForChild("Torso")
  392. local Animation = script:WaitForChild("AttackAnim")
  393. local Yeti = Instance.new("Sound",Torso)
  394. Yeti.Volume = 1
  395. Yeti.SoundId = "http://www.roblox.com/asset/?id=38212101"
  396. Spawn(function() Yeti:Play() end)
  397. local Hit1 = Instance.new("Sound",Torso)
  398. Hit1.Volume = 1
  399. Hit1.SoundId = "http://www.roblox.com/asset/?id=2801263"
  400. local Hit2 = Instance.new("Sound",Torso)
  401. Hit2.Volume = 1
  402. Hit2.SoundId = "http://www.roblox.com/asset/?id=38212101"
  403.  
  404. local AttackEnabled = true
  405.  
  406. function wait(TimeToWait)
  407. if TimeToWait ~= nil then
  408. local TotalTime = 0
  409. TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
  410. while TotalTime < TimeToWait do
  411. TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
  412. end
  413. else
  414. game:GetService("RunService").Heartbeat:wait()
  415. end
  416. end
  417.  
  418. function DamageTag(parent,damage)
  419. local DmgTag = script.DamageTag:clone()
  420. DmgTag.Damage.Value = damage
  421. DmgTag.creator.Value = game.Players.LocalPlayer
  422. DmgTag.Disabled = false
  423. DmgTag.Parent = parent
  424. end
  425.  
  426. local Anim = Humanoid:LoadAnimation(Animation)
  427. function Hit(hit)
  428. local TargetHum = hit.Parent:FindFirstChild("Humanoid")
  429. if TargetHum ~= nil and TargetHum:IsA("Humanoid") and AttackEnabled == true and TargetHum ~= Humanoid then
  430. AttackEnabled = false
  431. Delay(0.5,function() AttackEnabled = true end)
  432. if Anim then Anim:Play(nil,nil,1.5) end
  433. DamageTag(TargetHum.Parent,125)
  434. Hit1:Play()
  435. Hit2:Play()
  436. end
  437. end
  438.  
  439. for _, Child in pairs(script.Parent:GetChildren()) do
  440. if Child:IsA("Part") or Child:IsA("WedgePart") or Child:IsA("CornerWedgePart") then
  441. Child.Touched:connect(Hit)
  442. end
  443. end
  444.  
  445. end))
  446. Script26.Name = "DamageTag"
  447. Script26.Parent = Script25
  448. table.insert(cors,sandbox(Script26,function()
  449. wait()
  450. h = script.Parent:findFirstChild("Humanoid")
  451. if h ~= nil then
  452. while h:findFirstChild("creator") do
  453. h.creator:Destroy()
  454. end
  455. tag = script.creator:clone()
  456. tag.Parent = h
  457. game.Debris:AddItem(tag,5)
  458. h:TakeDamage(script.Damage.Value)
  459. end
  460. script:remove()
  461. end))
  462. Script26.Disabled = true
  463. NumberValue27.Name = "Damage"
  464. NumberValue27.Parent = Script26
  465. ObjectValue28.Name = "creator"
  466. ObjectValue28.Parent = Script26
  467. Animation29.Name = "AttackAnim"
  468. Animation29.Parent = Script25
  469. Animation29.AnimationId = "http://www.roblox.com/Asset?ID=105211514"
  470. Script30.Name = "Animate"
  471. Script30.Parent = Model0
  472. table.insert(cors,sandbox(Script30,function()
  473. function waitForChild(parent, childName)
  474. local child = parent:findFirstChild(childName)
  475. if child then return child end
  476. while true do
  477. child = parent.ChildAdded:wait()
  478. if child.Name==childName then return child end
  479. end
  480. end
  481.  
  482. local Figure = script.Parent
  483. local Torso = waitForChild(Figure, "Torso")
  484. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  485. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  486. local RightHip = waitForChild(Torso, "Right Hip")
  487. local LeftHip = waitForChild(Torso, "Left Hip")
  488. local Neck = waitForChild(Torso, "Neck")
  489. local Zombie = waitForChild(Figure, "Zombie")
  490. local pose = "Standing"
  491.  
  492. local currentAnim = ""
  493. local currentAnimInstance = nil
  494. local currentAnimTrack = nil
  495. local currentAnimKeyframeHandler = nil
  496. local currentAnimSpeed = 1.0
  497. local animTable = {}
  498. local animNames = {
  499. idle = {
  500. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  501. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  502. },
  503. walk = {
  504. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  505. },
  506. run = {
  507. { id = "run.xml", weight = 10 }
  508. },
  509. jump = {
  510. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  511. },
  512. fall = {
  513. { id = "http://www.roblox.com/asset/?id=305752857", weight = 10 }
  514. },
  515. climb = {
  516. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  517. },
  518. sit = {
  519. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  520. },
  521. toolnone = {
  522. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  523. },
  524. toolslash = {
  525. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  526. -- { id = "slash.xml", weight = 10 }
  527. },
  528. toollunge = {
  529. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  530. },
  531. wave = {
  532. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  533. },
  534. point = {
  535. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  536. },
  537. dance = {
  538. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  539. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  540. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  541. },
  542. dance2 = {
  543. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  544. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  545. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  546. },
  547. dance3 = {
  548. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  549. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  550. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  551. },
  552. laugh = {
  553. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  554. },
  555. cheer = {
  556. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  557. },
  558. }
  559.  
  560. -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
  561. local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
  562.  
  563. math.randomseed(tick())
  564.  
  565. function configureAnimationSet(name, fileList)
  566. if (animTable[name] ~= nil) then
  567. for _, connection in pairs(animTable[name].connections) do
  568. connection:disconnect()
  569. end
  570. end
  571. animTable[name] = {}
  572. animTable[name].count = 0
  573. animTable[name].totalWeight = 0
  574. animTable[name].connections = {}
  575.  
  576. -- check for config values
  577. local config = script:FindFirstChild(name)
  578. if (config ~= nil) then
  579. -- print("Loading anims " .. name)
  580. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  581. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  582. local idx = 1
  583. for _, childPart in pairs(config:GetChildren()) do
  584. if (childPart:IsA("Animation")) then
  585. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  586. animTable[name][idx] = {}
  587. animTable[name][idx].anim = childPart
  588. local weightObject = childPart:FindFirstChild("Weight")
  589. if (weightObject == nil) then
  590. animTable[name][idx].weight = 1
  591. else
  592. animTable[name][idx].weight = weightObject.Value
  593. end
  594. animTable[name].count = animTable[name].count + 1
  595. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  596. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  597. idx = idx + 1
  598. end
  599. end
  600. end
  601.  
  602. -- fallback to defaults
  603. if (animTable[name].count <= 0) then
  604. for idx, anim in pairs(fileList) do
  605. animTable[name][idx] = {}
  606. animTable[name][idx].anim = Instance.new("Animation")
  607. animTable[name][idx].anim.Name = name
  608. animTable[name][idx].anim.AnimationId = anim.id
  609. animTable[name][idx].weight = anim.weight
  610. animTable[name].count = animTable[name].count + 1
  611. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  612. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  613. end
  614. end
  615. end
  616.  
  617. -- Setup animation objects
  618. function scriptChildModified(child)
  619. local fileList = animNames[child.Name]
  620. if (fileList ~= nil) then
  621. configureAnimationSet(child.Name, fileList)
  622. end
  623. end
  624.  
  625. script.ChildAdded:connect(scriptChildModified)
  626. script.ChildRemoved:connect(scriptChildModified)
  627.  
  628.  
  629. for name, fileList in pairs(animNames) do
  630. configureAnimationSet(name, fileList)
  631. end
  632.  
  633. -- ANIMATION
  634.  
  635. -- declarations
  636. local toolAnim = "None"
  637. local toolAnimTime = 0
  638.  
  639. local jumpAnimTime = 0
  640. local jumpAnimDuration = 0.3
  641.  
  642. local toolTransitionTime = 0.1
  643. local fallTransitionTime = 0.3
  644. local jumpMaxLimbVelocity = 0.75
  645.  
  646. -- functions
  647.  
  648. function stopAllAnimations()
  649. local oldAnim = currentAnim
  650.  
  651. -- return to idle if finishing an emote
  652. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  653. oldAnim = "idle"
  654. end
  655.  
  656. currentAnim = ""
  657. currentAnimInstance = nil
  658. if (currentAnimKeyframeHandler ~= nil) then
  659. currentAnimKeyframeHandler:disconnect()
  660. end
  661.  
  662. if (currentAnimTrack ~= nil) then
  663. currentAnimTrack:Stop()
  664. currentAnimTrack:Destroy()
  665. currentAnimTrack = nil
  666. end
  667. return oldAnim
  668. end
  669.  
  670. function setAnimationSpeed(speed)
  671. if speed ~= currentAnimSpeed then
  672. currentAnimSpeed = speed
  673. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  674. end
  675. end
  676.  
  677. function keyFrameReachedFunc(frameName)
  678. if (frameName == "End") then
  679.  
  680. local repeatAnim = currentAnim
  681. -- return to idle if finishing an emote
  682. if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
  683. repeatAnim = "idle"
  684. end
  685.  
  686. local animSpeed = currentAnimSpeed
  687. playAnimation(repeatAnim, 0.0, Zombie)
  688. setAnimationSpeed(animSpeed)
  689. end
  690. end
  691.  
  692. -- Preload animations
  693. function playAnimation(animName, transitionTime, Zombie)
  694.  
  695. local roll = math.random(1, animTable[animName].totalWeight)
  696. local origRoll = roll
  697. local idx = 1
  698. while (roll > animTable[animName][idx].weight) do
  699. roll = roll - animTable[animName][idx].weight
  700. idx = idx + 1
  701. end
  702. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  703. local anim = animTable[animName][idx].anim
  704.  
  705. -- switch animation
  706. if (anim ~= currentAnimInstance) then
  707.  
  708. if (currentAnimTrack ~= nil) then
  709. currentAnimTrack:Stop(transitionTime)
  710. currentAnimTrack:Destroy()
  711. end
  712.  
  713. currentAnimSpeed = 1.0
  714.  
  715. -- load it to the Zombie; get AnimationTrack
  716. currentAnimTrack = Zombie:LoadAnimation(anim)
  717.  
  718. -- play the animation
  719. currentAnimTrack:Play(transitionTime)
  720. currentAnim = animName
  721. currentAnimInstance = anim
  722.  
  723. -- set up keyframe name triggers
  724. if (currentAnimKeyframeHandler ~= nil) then
  725. currentAnimKeyframeHandler:disconnect()
  726. end
  727. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  728.  
  729. end
  730.  
  731. end
  732.  
  733. -------------------------------------------------------------------------------------------
  734. -------------------------------------------------------------------------------------------
  735.  
  736. local toolAnimName = ""
  737. local toolAnimTrack = nil
  738. local toolAnimInstance = nil
  739. local currentToolAnimKeyframeHandler = nil
  740.  
  741. function toolKeyFrameReachedFunc(frameName)
  742. if (frameName == "End") then
  743. -- print("Keyframe : ".. frameName)
  744. playToolAnimation(toolAnimName, 0.0, Zombie)
  745. end
  746. end
  747.  
  748.  
  749. function playToolAnimation(animName, transitionTime, Zombie)
  750.  
  751. local roll = math.random(1, animTable[animName].totalWeight)
  752. local origRoll = roll
  753. local idx = 1
  754. while (roll > animTable[animName][idx].weight) do
  755. roll = roll - animTable[animName][idx].weight
  756. idx = idx + 1
  757. end
  758. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  759. local anim = animTable[animName][idx].anim
  760.  
  761. if (toolAnimInstance ~= anim) then
  762.  
  763. if (toolAnimTrack ~= nil) then
  764. toolAnimTrack:Stop()
  765. toolAnimTrack:Destroy()
  766. transitionTime = 0
  767. end
  768.  
  769. -- load it to the Zombie; get AnimationTrack
  770. toolAnimTrack = Zombie:LoadAnimation(anim)
  771.  
  772. -- play the animation
  773. toolAnimTrack:Play(transitionTime)
  774. toolAnimName = animName
  775. toolAnimInstance = anim
  776.  
  777. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  778. end
  779. end
  780.  
  781. function stopToolAnimations()
  782. local oldAnim = toolAnimName
  783.  
  784. if (currentToolAnimKeyframeHandler ~= nil) then
  785. currentToolAnimKeyframeHandler:disconnect()
  786. end
  787.  
  788. toolAnimName = ""
  789. toolAnimInstance = nil
  790. if (toolAnimTrack ~= nil) then
  791. toolAnimTrack:Stop()
  792. toolAnimTrack:Destroy()
  793. toolAnimTrack = nil
  794. end
  795.  
  796.  
  797. return oldAnim
  798. end
  799.  
  800. -------------------------------------------------------------------------------------------
  801. -------------------------------------------------------------------------------------------
  802.  
  803.  
  804. function onRunning(speed)
  805. if speed>0.01 then
  806. playAnimation("walk", 0.1, Zombie)
  807. if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
  808. setAnimationSpeed(speed / 14.5)
  809. end
  810. pose = "Running"
  811. else
  812. playAnimation("idle", 0.1, Zombie)
  813. pose = "Standing"
  814. end
  815. end
  816.  
  817. function onDied()
  818. pose = "Dead"
  819. end
  820.  
  821. function onJumping()
  822. playAnimation("jump", 0.1, Zombie)
  823. jumpAnimTime = jumpAnimDuration
  824. pose = "Jumping"
  825. end
  826.  
  827. function onClimbing(speed)
  828. playAnimation("climb", 0.1, Zombie)
  829. setAnimationSpeed(speed / 12.0)
  830. pose = "Climbing"
  831. end
  832.  
  833. function onGettingUp()
  834. pose = "GettingUp"
  835. end
  836.  
  837. function onFreeFall()
  838. if (jumpAnimTime <= 0) then
  839. playAnimation("fall", fallTransitionTime, Zombie)
  840. end
  841. pose = "FreeFall"
  842. end
  843.  
  844. function onFallingDown()
  845. pose = "FallingDown"
  846. end
  847.  
  848. function onSeated()
  849. pose = "Seated"
  850. end
  851.  
  852. function onPlatformStanding()
  853. pose = "PlatformStanding"
  854. end
  855.  
  856. function onSwimming(speed)
  857. if speed>0 then
  858. pose = "Running"
  859. else
  860. pose = "Standing"
  861. end
  862. end
  863.  
  864. function getTool()
  865. for _, kid in ipairs(Figure:GetChildren()) do
  866. if kid.className == "Tool" then return kid end
  867. end
  868. return nil
  869. end
  870.  
  871. function getToolAnim(tool)
  872. for _, c in ipairs(tool:GetChildren()) do
  873. if c.Name == "toolanim" and c.className == "StringValue" then
  874. return c
  875. end
  876. end
  877. return nil
  878. end
  879.  
  880. function animateTool()
  881.  
  882. if (toolAnim == "None") then
  883. playToolAnimation("toolnone", toolTransitionTime, Zombie)
  884. return
  885. end
  886.  
  887. if (toolAnim == "Slash") then
  888. playToolAnimation("toolslash", 0, Zombie)
  889. return
  890. end
  891.  
  892. if (toolAnim == "Lunge") then
  893. playToolAnimation("toollunge", 0, Zombie)
  894. return
  895. end
  896. end
  897.  
  898. function moveSit()
  899. RightShoulder.MaxVelocity = 0.15
  900. LeftShoulder.MaxVelocity = 0.15
  901. RightShoulder:SetDesiredAngle(3.14 /2)
  902. LeftShoulder:SetDesiredAngle(-3.14 /2)
  903. RightHip:SetDesiredAngle(3.14 /2)
  904. LeftHip:SetDesiredAngle(-3.14 /2)
  905. end
  906.  
  907. local lastTick = 0
  908.  
  909. function move(time)
  910. local amplitude = 1
  911. local frequency = 1
  912. local deltaTime = time - lastTick
  913. lastTick = time
  914.  
  915. local climbFudge = 0
  916. local setAngles = false
  917.  
  918. if (jumpAnimTime > 0) then
  919. jumpAnimTime = jumpAnimTime - deltaTime
  920. end
  921.  
  922. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  923. playAnimation("fall", fallTransitionTime, Zombie)
  924. elseif (pose == "Seated") then
  925. playAnimation("sit", 0.5, Zombie)
  926. return
  927. elseif (pose == "Running") then
  928. playAnimation("walk", 0.1, Zombie)
  929. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  930. -- print("Wha " .. pose)
  931. stopAllAnimations()
  932. amplitude = 0.1
  933. frequency = 1
  934. setAngles = true
  935. end
  936.  
  937. if (setAngles) then
  938. desiredAngle = amplitude * math.sin(time * frequency)
  939.  
  940. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  941. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  942. RightHip:SetDesiredAngle(-desiredAngle)
  943. LeftHip:SetDesiredAngle(-desiredAngle)
  944. end
  945.  
  946. -- Tool Animation handling
  947. local tool = getTool()
  948. if tool and tool:FindFirstChild("Handle") then
  949.  
  950. animStringValueObject = getToolAnim(tool)
  951.  
  952. if animStringValueObject then
  953. toolAnim = animStringValueObject.Value
  954. -- message recieved, delete StringValue
  955. animStringValueObject.Parent = nil
  956. toolAnimTime = time + .3
  957. end
  958.  
  959. if time > toolAnimTime then
  960. toolAnimTime = 0
  961. toolAnim = "None"
  962. end
  963.  
  964. animateTool()
  965. else
  966. stopToolAnimations()
  967. toolAnim = "None"
  968. toolAnimInstance = nil
  969. toolAnimTime = 0
  970. end
  971. end
  972.  
  973. -- connect events
  974. Zombie.Died:connect(onDied)
  975. Zombie.Running:connect(onRunning)
  976. Zombie.Jumping:connect(onJumping)
  977. Zombie.Climbing:connect(onClimbing)
  978. Zombie.GettingUp:connect(onGettingUp)
  979. Zombie.FreeFalling:connect(onFreeFall)
  980. Zombie.FallingDown:connect(onFallingDown)
  981. Zombie.Seated:connect(onSeated)
  982. Zombie.PlatformStanding:connect(onPlatformStanding)
  983. Zombie.Swimming:connect(onSwimming)
  984.  
  985. -- setup emote chat hook
  986. Game.Players.LocalPlayer.Chatted:connect(function(msg)
  987. local emote = ""
  988. if (string.sub(msg, 1, 3) == "/e ") then
  989. emote = string.sub(msg, 4)
  990. elseif (string.sub(msg, 1, 7) == "/emote ") then
  991. emote = string.sub(msg, 8)
  992. end
  993.  
  994. if (pose == "Standing" and emoteNames[emote] ~= nil) then
  995. playAnimation(emote, 0.1, Zombie)
  996. end
  997.  
  998. end)
  999.  
  1000.  
  1001. -- main program
  1002.  
  1003. local runService = game:service("RunService");
  1004.  
  1005. -- initialize to idle
  1006. playAnimation("idle", 0.1, Zombie)
  1007. pose = "Standing"
  1008.  
  1009. while Figure.Parent~=nil do
  1010. local _, time = wait(0.1)
  1011. move(time)
  1012. end
  1013.  
  1014.  
  1015.  
  1016.  
  1017. end))
  1018. StringValue31.Name = "climb"
  1019. StringValue31.Parent = Script30
  1020. Animation32.Name = "ClimbAnim"
  1021. Animation32.Parent = StringValue31
  1022. Animation32.AnimationId = "http://www.roblox.com/asset/?id=180436334"
  1023. StringValue33.Name = "fall"
  1024. StringValue33.Parent = Script30
  1025. Animation34.Name = "FallAnim"
  1026. Animation34.Parent = StringValue33
  1027. Animation34.AnimationId = "http://www.roblox.com/asset/?id=180436148"
  1028. StringValue35.Name = "idle"
  1029. StringValue35.Parent = Script30
  1030. Animation36.Name = "Animation1"
  1031. Animation36.Parent = StringValue35
  1032. Animation36.AnimationId = "http://www.roblox.com/asset/?id=180435571"
  1033. NumberValue37.Name = "Weight"
  1034. NumberValue37.Parent = Animation36
  1035. NumberValue37.Value = 9
  1036. Animation38.Name = "Animation2"
  1037. Animation38.Parent = StringValue35
  1038. Animation38.AnimationId = "http://www.roblox.com/asset/?id=180435792"
  1039. NumberValue39.Name = "Weight"
  1040. NumberValue39.Parent = Animation38
  1041. NumberValue39.Value = 1
  1042. StringValue40.Name = "jump"
  1043. StringValue40.Parent = Script30
  1044. Animation41.Name = "JumpAnim"
  1045. Animation41.Parent = StringValue40
  1046. Animation41.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  1047. StringValue42.Name = "run"
  1048. StringValue42.Parent = Script30
  1049. Animation43.Name = "RunAnim"
  1050. Animation43.Parent = StringValue42
  1051. Animation43.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  1052. StringValue44.Name = "sit"
  1053. StringValue44.Parent = Script30
  1054. Animation45.Name = "SitAnim"
  1055. Animation45.Parent = StringValue44
  1056. Animation45.AnimationId = "http://www.roblox.com/asset/?id=178130996"
  1057. StringValue46.Name = "toolnone"
  1058. StringValue46.Parent = Script30
  1059. Animation47.Name = "ToolNoneAnim"
  1060. Animation47.Parent = StringValue46
  1061. Animation47.AnimationId = "http://www.roblox.com/asset/?id=182393478"
  1062. StringValue48.Name = "walk"
  1063. StringValue48.Parent = Script30
  1064. Animation49.Name = "WalkAnim"
  1065. Animation49.Parent = StringValue48
  1066. Animation49.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  1067. Camera50.Name = "ThumbnailCamera"
  1068. Camera50.Parent = Model0
  1069. Camera50.CFrame = CFrame.new(-120.427315, 8.9444809, -67.5636902, 0.6640172, 0.0586584844, -0.745412886, 3.7252903e-09, 0.996918142, 0.0784500837, 0.747717321, -0.0520922095, 0.661970794)
  1070. Camera50.CoordinateFrame = CFrame.new(-120.427315, 8.9444809, -67.5636902, 0.6640172, 0.0586584844, -0.745412886, 3.7252903e-09, 0.996918142, 0.0784500837, 0.747717321, -0.0520922095, 0.661970794)
  1071. Camera50.Focus = CFrame.new(-118.936478, 8.78757954, -68.8876419, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  1072. Camera50.focus = CFrame.new(-118.936478, 8.78757954, -68.8876419, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  1073. Pants51.Name = "Pants"
  1074. Pants51.Parent = Model0
  1075. Pants51.PantsTemplate = "rbxassetid://949284975"
  1076. Shirt52.Name = "Shirt"
  1077. Shirt52.Parent = Model0
  1078. Shirt52.ShirtTemplate = "rbxassetid://573188703"
  1079. Folder53.Name = "[1] Global Background Music"
  1080. Folder53.Parent = Model0
  1081. Sound54.Parent = Folder53
  1082. Sound54.EmitterSize = 0
  1083. Sound54.MinDistance = 0
  1084. Sound54.SoundId = "rbxassetid://321451733"
  1085. Sound54.Volume = 0.44999998807907
  1086. Script55.Name = "**README / INSTRUCTIONS**"
  1087. Script55.Parent = Folder53
  1088. table.insert(cors,sandbox(Script55,function()
  1089. -- Cindering
  1090. -- Twitter: @Cindering_
  1091.  
  1092. --[[
  1093.  
  1094. Hey there! This model gives you the tools to easily set up background music in your game. You can set up global background music (music that simply plays for everyone in the game), zone-specific background music (tracks that only play when you enter a certain area), or both!
  1095. This script contains instructions for both methods of adding background music.
  1096.  
  1097.  
  1098. CONTENTS:
  1099. I. Global Background Music (SIMPLE SETUP)
  1100. II. Zone-Specific Background Music
  1101. a. How Background Music Zones Work
  1102. b. Setting Up Music Zones
  1103.  
  1104.  
  1105. ------------------------------------------------------
  1106.  
  1107. I. Global Background Music (SIMPLE SETUP)
  1108.  
  1109. ------------------------------------------------------
  1110.  
  1111. If you just want to quickly add a piece of global background music to your entire game, then all you have to do is follow these simple steps:
  1112.  
  1113.  
  1114. 1. Go onto the ROBLOX site and find the Audio you wish to use.
  1115.  
  1116. (( You can search for audio via the Develop Library: https://www.roblox.com/develop/library?CatalogContext=DevelopOnly&Category=Audio ))
  1117.  
  1118.  
  1119. 2. Once you're on the desired Audio asset's page, copy the numeric ID you see at the end of the URL (website address bar).
  1120.  
  1121. (( For example, if you want to use this audio in your game: https://www.roblox.com/Audio-Name-Here-item?id=214852782
  1122. ...then you copy the ID, which is 214852782. ))
  1123.  
  1124.  
  1125. 3. Inside of this model, you will see a folder named "Global Background Music" which contains a Sound object. Click on the Sound, and then in the Properties menu, paste your Audio's ID into the SoundId property and press Enter. The SoundId property should now be filled in as "rbxassetid://AUDIO_ID_HERE".
  1126.  
  1127.  
  1128.  
  1129. And that's it! The music you've selected will now be played for everyone in your game. If you want, you can add multiple Sound objects to that folder to create a shuffled playlist of background music. (Tip: You can select the Sound object and press Ctrl + D to duplicate it, then change the SoundId of the new one.) You can also adjust the volume of the music (or even the pitch!) for more control.
  1130.  
  1131. Whenever the game runs, the toolkit's Auto-Install script will automatically move everything to the proper location and delete any unnecessary leftovers. You don't have to do anything else!
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139. ------------------------------------------------------
  1140.  
  1141. II. Zone-Specific Background Music
  1142.  
  1143. ------------------------------------------------------
  1144.  
  1145. Set up specific areas for certain music tracks to play in. Want to select one song that plays in the outdoors, and another song that plays in a specific building? Set this all up with ease.
  1146.  
  1147.  
  1148.  
  1149. -----------------------------------------
  1150.  
  1151. 2a. How Background Music Zones Work:
  1152.  
  1153. -----------------------------------------
  1154.  
  1155. A Music Zone is a model contained within the Background Music Zones folder.
  1156. The part(s) placed inside one of those models represent the physical space in which the zone's music will be played.
  1157.  
  1158. Simply put, players who walk inside of that zone's parts will hear the music that you have selected for that zone.
  1159.  
  1160.  
  1161. Each zone contains the following objects:
  1162.  
  1163. -- Music (Folder): This folder contains the Sound object(s) which will be used as music for that zone. If you only have one Sound object in there, that will be used as the sole music track for that zone. Otherwise, multiple Sound objects will allow for a shuffled playlist of music.
  1164.  
  1165. -- Parts: The parts inside of the zone represent the physical area in which the zone's music will be played, as explained above. You may use multiple parts for each zone.
  1166.  
  1167. -- Priority (IntValue): Priority determines which zone's music will be played when a player is standing inside of multiple overlapping zones.
  1168.  
  1169. If a player moves into an overlapping zone of...
  1170. - EQUAL OR LOWER PRIORITY: the current music will continue to play.
  1171. - HIGHER PRIORITY: the new zone's music will start playing immediately.
  1172.  
  1173. This is useful if, for example, you have a small building that you want to play unique music inside of, but the building overlaps with another larger music zone. Set the Priority of the building's music zone to be higher.
  1174.  
  1175. You are allowed to create as many different music zones as you want.
  1176.  
  1177.  
  1178.  
  1179. ****PERFORMANCE WITH ROTATED ZONE PARTS****
  1180.  
  1181. For optimal script performance, it is recommended that you do not rotate music zones' parts at any non-90 degree increments.
  1182.  
  1183. If you place the zone parts with irregular rotations, this forces the script to use the more expensive GetTouchingParts() function to determine if the character is inside of that specific part. It will still work, but it may create some lag if you do this a lot in areas with many parts.
  1184.  
  1185. Whereas if you just have zone parts placed at regular 90 degree rotation increments, the script will be able to use simple, inexpensive position comparisons on the character.
  1186.  
  1187.  
  1188.  
  1189.  
  1190. -----------------------------------------
  1191.  
  1192. 2b. Setting Up Music Zones
  1193.  
  1194. -----------------------------------------
  1195.  
  1196. Now that you know how they work, here are the basic steps for setting up background music zones:
  1197.  
  1198.  
  1199. 1. Create a Model which contains all of the necessary components for a zone (an IntValue named "Priority", a Folder named "Music", and Parts that will represent the physical area of the zone) in the Background Music Zones folder. Give the model a unique name.
  1200.  
  1201. Tip: You may select the "Test Zone" and press Ctrl + D to easily duplicate the necessary components.
  1202.  
  1203.  
  1204. 2. Insert Part(s) inside of this model, and move + resize them to fill the area in which you want this zone's music to be played.
  1205. Parts are allowed to overlap, even with parts of different music zones (which is when the Priority settings come into play).
  1206. Color coding each zone is highly recommended.
  1207.  
  1208.  
  1209. 3. Inside the zone's Music folder, create a Sound object to use as the music track for that zone. Copy your desired Audio ID (the number at the end of the Audio page's URL) and paste it into the Sound object's SoundId property. The value should then look like "rbxassetid://AUDIO_ID_HERE". You can also adjust the Volume or the Pitch if necessary.
  1210.  
  1211. (As explained in the above section, you can place multiple Sound objects into the Music folder to create a shuffled playlist.)
  1212.  
  1213.  
  1214. 4. Ensure that the zone's Priority is set to the desired value.
  1215.  
  1216. (As explained in the above section, Priority determines which music will play if a player is standing inside of two overlapping music zones. Zones with higher Priority take precedence over others.)
  1217.  
  1218.  
  1219. 5. Repeat steps 1-4 for each new music zone that you wish to create.
  1220.  
  1221.  
  1222. 6. Once you are done editing all of your music zones, you can drag the entire "Background Music Zones" Folder into ReplicatedStorage so that the zone parts don't get in the way of your building. (You can always move the folder back into the Workspace if you need to make edits in the future)
  1223.  
  1224. (You also can paste this line into Studio's Command Bar to move the folder to ReplicatedStorage):
  1225. workspace["Cindering's Background Music Toolkit"]["[2] Background Music Zones"].Parent = game.ReplicatedStorage
  1226. (And to move it back into this toolkit):
  1227. game.ReplicatedStorage["[2] Background Music Zones"].Parent = workspace["Cindering's Background Music Toolkit"]
  1228.  
  1229.  
  1230. 7. Open the "Settings" ModuleScript in the toolkit. Set settings.UseMusicZones to true. If you don't want to use Global Background Music, set settings.UseGlobalBackgroundMusic to false. Make any other settings adjustments that you'd like.
  1231.  
  1232.  
  1233.  
  1234. And you're done! You will now have unique music tracks playing in each of the different areas in your game. Whenever the game runs, the toolkit's Auto-Install script will automatically move everything to the proper location and delete any unnecessary leftovers from this toolkit.
  1235.  
  1236.  
  1237.  
  1238. Thanks for using my background music toolkit! I hope this has helped ease the process of adding background music to your game.
  1239.  
  1240. -- Cindering
  1241. -- Twitter: @Cindering_
  1242.  
  1243. --]]
  1244. end))
  1245. Script56.Name = "Auto-Install"
  1246. Script56.Parent = Folder53
  1247. table.insert(cors,sandbox(Script56,function()
  1248. -- Cindering
  1249. -- Twitter: @Cindering_
  1250.  
  1251. --[[
  1252.  
  1253. When the game is run, this script automatically places all of the model's contents into the correct locations and deletes any leftover clutter.
  1254.  
  1255. All you have to do is configure the music IDs and/or zones as described in the README - the rest will be automatically handled!
  1256.  
  1257. --]]
  1258.  
  1259. local settings = require(script.Parent.Settings)
  1260.  
  1261. if settings.UseGlobalBackgroundMusic == false and settings.UseMusicZones == false then
  1262. error("Cindering's BGM error: You have disabled both Global Background Music and Music Zones. You must change at least one of these settings to 'true'.")
  1263. return
  1264. end
  1265.  
  1266. local name1 = "[1] Global Background Music"
  1267. local name2 = "[2] Background Music Zones"
  1268.  
  1269. local container = Instance.new("Folder")
  1270. container.Name = "CinderingBGM"
  1271.  
  1272. script.Parent.Settings.Parent = container
  1273.  
  1274. script.LocalBackgroundMusic.Parent = game.StarterPlayer.StarterPlayerScripts
  1275.  
  1276. local music = Instance.new("Folder")
  1277. local zones = Instance.new("Folder",music)
  1278. zones.Name = "MusicZones"
  1279. local global = Instance.new("Folder",music)
  1280. global.Name = "GlobalMusic"
  1281.  
  1282. if settings.UseMusicZones == true then
  1283. local folder = script.Parent:FindFirstChild(name2) or game.ReplicatedStorage:FindFirstChild(name2) or workspace:FindFirstChild(name2) or game:FindFirstChild(name2,true) -- never know where someone might accidentally drag that folder...
  1284.  
  1285. if folder then
  1286. for _,model in pairs(folder:GetChildren()) do
  1287. if (model:IsA("Model") and model:FindFirstChild("Music")) then
  1288. model.Parent = zones
  1289. end
  1290. end
  1291. else
  1292. error("Cindering's BGM error: Your background music zones folder could not be found! You may have deleted/renamed the original folder. It should be named: "..name2)
  1293. return
  1294. end
  1295. end
  1296.  
  1297. if settings.UseGlobalBackgroundMusic == true then
  1298. local folder = script.Parent:FindFirstChild(name1) or game.ReplicatedStorage:FindFirstChild(name1) or workspace:FindFirstChild(name1) or game:FindFirstChild(name1,true)
  1299.  
  1300. if folder then
  1301. for _,v in pairs(folder:GetChildren()) do
  1302. if v:IsA("Sound") then
  1303. v.Parent = global
  1304. end
  1305. end
  1306. else
  1307. error("Cindering's BGM error: Your global background music folder could not be found! You may have deleted/renamed the original folder. It should be named: "..name1)
  1308. return
  1309. end
  1310. end
  1311.  
  1312. if settings.UseGlobalBackgroundMusic == true and #global:GetChildren() == 0 then
  1313. warn("Cindering's BGM warning: Your global background music folder is completely empty; no music will be played from there.")
  1314. end
  1315. if settings.UseMusicZones == true and #zones:GetChildren() == 0 then
  1316. warn("Cindering's BGM warning: Your background music zones folder is completely empty; no music will be played from there.")
  1317. end
  1318.  
  1319. music.Name = "MusicFolder"
  1320. music.Parent = container
  1321.  
  1322. local count = 0
  1323. function recurse(instance)
  1324. for _,v in pairs(instance:GetChildren()) do
  1325. count = count + 1
  1326. recurse(v)
  1327. end
  1328. end
  1329. recurse(music)
  1330. local val = Instance.new("IntValue",container)
  1331. val.Name = "ObjectCount"
  1332. val.Value = count
  1333.  
  1334. container.Parent = game.ReplicatedStorage
  1335.  
  1336. script.Parent:Destroy()
  1337. end))
  1338. LocalScript57.Name = "LocalBackgroundMusic"
  1339. LocalScript57.Parent = Script56
  1340. table.insert(cors,sandbox(LocalScript57,function()
  1341. -- Cindering
  1342. -- Twitter: @Cindering_
  1343.  
  1344. -- This script gets placed into StarterPlayerScripts where it will locally play the background music for each player.
  1345.  
  1346. local plr = game.Players.LocalPlayer
  1347. local char
  1348. local torso
  1349.  
  1350. local container = game.ReplicatedStorage:WaitForChild("CinderingBGM")
  1351. local settings = require(container:WaitForChild("Settings"))
  1352. local musicfolder = container:WaitForChild("MusicFolder")
  1353. local globalfolder = musicfolder:WaitForChild("GlobalMusic")
  1354. local zonesfolder = musicfolder:WaitForChild("MusicZones")
  1355. local servercount = container:WaitForChild("ObjectCount").Value
  1356.  
  1357. function GetMatchingCount() --objects can take some time to actually replicate to the client. make sure that the client sees the correct # of objects in the music folder before initializing the rest of the script
  1358. local count = 0
  1359. local function recurse(instance)
  1360. for _,v in pairs(instance:GetChildren()) do
  1361. count = count + 1
  1362. recurse(v)
  1363. end
  1364. end
  1365. recurse(musicfolder)
  1366. if count == servercount then return true end
  1367. end
  1368.  
  1369. while not GetMatchingCount() do
  1370. wait(.5)
  1371. end
  1372.  
  1373.  
  1374. function IsCleanRotation(v3values) --check to see whether the rotation is at clean 90 degree increments so we can use the more simplistic calculations for it
  1375. for _,v in pairs(v3values) do
  1376. if not (v%90 <= 0.01 or v%90 >= 89.99) then --why not just check for (v%90 == 0)? because rotations can suffer from floating point inaccuracies
  1377. return false
  1378. end
  1379. end
  1380. return true
  1381. end
  1382.  
  1383.  
  1384. --now, load the zone & music data into the script
  1385.  
  1386. local zones = {}
  1387. local music = {}
  1388. local globali
  1389.  
  1390. if settings.UseMusicZones == true then
  1391. for i,zone in pairs(zonesfolder:GetChildren()) do
  1392. if zone:IsA("Model") and zone:FindFirstChild("Music") then
  1393. music[i] = {}
  1394. for _,sound in pairs(zone.Music:GetChildren()) do --save all of the music data for this zone
  1395. if sound:IsA("Sound") then
  1396. table.insert(music[i], {["SoundId"] = sound.SoundId, ["Volume"] = sound.Volume, ["Pitch"] = sound.Pitch})
  1397. end
  1398. end
  1399.  
  1400. zones[i] = {
  1401. ["Priority"] = zone:FindFirstChild("Priority") and zone.Priority.Value or 1,
  1402. ["Parts"] = {},
  1403. ["Music"] = music[i]
  1404. }
  1405.  
  1406. for _,part in pairs(zone:GetChildren()) do
  1407. if part:IsA("Part") then
  1408.  
  1409. if IsCleanRotation({part.Rotation.X,part.Rotation.Y,part.Rotation.Z}) == true then --store the min and max X/Y/Z position coordinates of this part
  1410. local lx,ly,lz = math.huge,math.huge,math.huge
  1411. local mx,my,mz = -math.huge,-math.huge,-math.huge
  1412. local function ApplyValues(p)
  1413. if p.x < lx then lx = p.x end
  1414. if p.x > mx then mx = p.x end
  1415. if p.y < ly then ly = p.y end
  1416. if p.y > my then my = p.y end
  1417. if p.z < lz then lz = p.z end
  1418. if p.z > mz then mz = p.z end
  1419. end
  1420. local points = {}
  1421. --a bunch of sloppy math stuff to calculate the coordinates on each of the part's faces so we can figure out the min and max values. mathematicians, pls don't kill me if i'm doing this terribly
  1422. local cf1 = part.CFrame
  1423. local cf2 = (part.CFrame * CFrame.Angles(0,math.pi/2,0))
  1424. local cf3 = (part.CFrame * CFrame.Angles(math.pi/2,0,0))
  1425. local lvz = (cf1.lookVector * (part.Size.Z/2))
  1426. local lvx = (cf2.lookVector * (part.Size.X/2))
  1427. local lvy = (cf3.lookVector * (part.Size.Y/2))
  1428. points[1] = cf1+lvz
  1429. points[2] = cf1-lvz
  1430. points[3] = cf2+lvx
  1431. points[4] = cf2-lvx
  1432. points[5] = cf3+lvy
  1433. points[6] = cf3-lvy
  1434. for _,p in pairs(points) do
  1435. ApplyValues(p)
  1436. end
  1437. table.insert(zones[i]["Parts"],{["Coordinates"] = {lx=lx,ly=ly,lz=lz, mx=mx,my=my,mz=mz}})
  1438. else --save a reference to the part itself to be used for GetTouchingParts(), since it has a complex rotation that can't be solved with my own feeble calculations
  1439. table.insert(zones[i]["Parts"],{["Part"] = part})
  1440. end
  1441.  
  1442. end
  1443. end
  1444. end
  1445. end
  1446. end
  1447.  
  1448. if settings.UseGlobalBackgroundMusic == true then
  1449. globali = #music + 1
  1450. music[globali] = {}
  1451. for _,sound in pairs(globalfolder:GetChildren()) do
  1452. if sound:IsA("Sound") then
  1453. table.insert(music[globali], {["SoundId"] = sound.SoundId, ["Volume"] = sound.Volume, ["Pitch"] = sound.Pitch})
  1454. end
  1455. end
  1456. end
  1457. --end this enormous, disgusting block of code
  1458.  
  1459.  
  1460. --mute button stuff
  1461. local canmute = settings.DisplayMuteButton
  1462. local clonegui
  1463. if canmute then
  1464. clonegui = script.MuteButtonGui:clone()
  1465. end
  1466. script.MuteButtonGui:Destroy()
  1467.  
  1468. local musicon = true
  1469.  
  1470. function SetButtonStyle(button)
  1471. button.Text = "Music: ".. (musicon and "ON" or "OFF")
  1472. button.Style = musicon and Enum.ButtonStyle.RobloxRoundDefaultButton or Enum.ButtonStyle.RobloxRoundDropdownButton
  1473. button.TextColor3 = musicon and Color3.new(1,1,1) or Color3.new(.2,.2,.23)
  1474. end
  1475.  
  1476. function CreateButton()
  1477. local gui = clonegui:clone()
  1478. local button = gui.Button
  1479. button.Visible = true
  1480. SetButtonStyle(button)
  1481. button.MouseButton1Click:connect(function()
  1482. musicon = not musicon
  1483. local bgm = script:FindFirstChild("BGM")
  1484. if bgm then
  1485. bgm.Volume = musicon and bgm.OriginalVolume.Value or 0
  1486. end
  1487. SetButtonStyle(button)
  1488. end)
  1489. gui.Parent = plr:WaitForChild("PlayerGui")
  1490. end
  1491.  
  1492. function CharInit()
  1493. char = plr.Character
  1494. torso = char:WaitForChild("HumanoidRootPart")
  1495. if canmute then CreateButton() end
  1496. end
  1497.  
  1498. if plr.Character and plr.Character.Parent ~= nil then
  1499. CharInit()
  1500. end
  1501. plr.CharacterAdded:connect(function()
  1502. CharInit()
  1503. end)
  1504.  
  1505. --now, get to playing the music
  1506.  
  1507. local FadeoutTime = settings.MusicFadeoutTime
  1508.  
  1509. function PlaySound(sounddata)
  1510. if sounddata == nil then return end
  1511. local sound = Instance.new("Sound")
  1512. sound.Looped = true
  1513. sound.SoundId = sounddata.SoundId
  1514. sound.Volume = musicon and sounddata.Volume or 0
  1515. local v = Instance.new("NumberValue",sound)
  1516. v.Name = "OriginalVolume"
  1517. v.Value = sounddata.Volume
  1518. sound.Pitch = sounddata.Pitch
  1519. sound.Name = "BGM"
  1520. sound.Parent = script
  1521. sound:Play()
  1522. end
  1523.  
  1524. function FadeOutSound(sound)
  1525. local basevol = sound.Volume
  1526. local count = math.ceil(30*FadeoutTime)
  1527. if count < 1 then
  1528. count = 1
  1529. end
  1530. for i=1,count do
  1531. if sound then
  1532. sound.Volume = sound.Volume - (basevol / count)
  1533. wait(1/30)
  1534. end
  1535. end
  1536. if sound then
  1537. sound:Stop()
  1538. sound:Destroy()
  1539. end
  1540. end
  1541.  
  1542.  
  1543. if settings.UseGlobalBackgroundMusic == true and settings.UseMusicZones == false then
  1544. if #music[globali] == 1 then --global BGM with just 1 song? ez pz
  1545. PlaySound(music[1][1])
  1546. return
  1547. elseif #music[globali] == 0 then --there's no music to play...?
  1548. return
  1549. end
  1550. end
  1551.  
  1552.  
  1553.  
  1554. local recentindices = {} --keeps track of recently selected indicies, so as not to play repeat music tracks
  1555. math.randomseed(tick())
  1556. local currentzone
  1557. local zoneplayingmusic
  1558.  
  1559. function CheckIfRecent(i)
  1560. for _,v in pairs(recentindices) do
  1561. if v == i then
  1562. return true
  1563. end
  1564. end
  1565. return false
  1566. end
  1567.  
  1568. function SelectRandomMusic(musiclist) --select a random number, excluding ones that were already used recently
  1569. if musiclist == nil or #musiclist == 0 then return end
  1570. local possiblenumbers = {}
  1571. local selectedindex
  1572. for i=1,#musiclist do
  1573. if not CheckIfRecent(i) then
  1574. table.insert(possiblenumbers,i)
  1575. end
  1576. end
  1577. local selectedindex = possiblenumbers[math.random(1,#possiblenumbers)]
  1578. table.insert(recentindices,selectedindex)
  1579. if #recentindices > math.ceil(#musiclist / 2) then
  1580. table.remove(recentindices,1)
  1581. end
  1582. return musiclist[selectedindex]
  1583. end
  1584.  
  1585. function IsInZone(zonedata)
  1586. if torso and torso.Parent ~= nil then
  1587. local p = torso.Position
  1588. for _,data in pairs(zonedata["Parts"]) do
  1589. if data["Coordinates"] then
  1590. local t = data["Coordinates"]
  1591. if (p.x > t.lx and p.x < t.mx and p.y > t.ly and p.y < t.my and p.z > t.lz and p.z < t.mz) then --is the character within all the coordinates of the zone?
  1592. return true
  1593. end
  1594. elseif data["Part"] then --complex part? create a clone of the part and check if it's touching the character's torso
  1595. local part = data["Part"]:clone()
  1596. part.Anchored = true
  1597. part.Parent = workspace.CurrentCamera or workspace
  1598. part.CanCollide = true
  1599. local touching = part:GetTouchingParts()
  1600. part:Destroy()
  1601. for _,v in pairs(touching) do
  1602. if v == torso then
  1603. return true
  1604. end
  1605. end
  1606. end
  1607. end
  1608. return false
  1609. end
  1610. end
  1611.  
  1612. function CalculateCurrentZone()
  1613. local priority = -math.huge
  1614. local oldzone = currentzone
  1615. local selectedzone
  1616. if currentzone then
  1617. if IsInZone(currentzone) then
  1618. selectedzone = currentzone
  1619. priority = currentzone["Priority"]
  1620. end
  1621. end
  1622. for _,zone in pairs(zones) do
  1623. if zone["Priority"] > priority and IsInZone(zone) then
  1624. priority = zone["Priority"]
  1625. selectedzone = zone
  1626. end
  1627. end
  1628. currentzone = selectedzone
  1629. if currentzone ~= oldzone and (currentzone ~= nil or settings.UseGlobalBackgroundMusic == true) then
  1630. recentindices = {}
  1631. end
  1632. return currentzone,oldzone
  1633. end
  1634.  
  1635.  
  1636. function RunCycle() --the main cycle which will continuously run, checking which zones (if any) the character is in and playing new music when necessary
  1637. local bgm = script:FindFirstChild("BGM")
  1638. if settings.UseMusicZones == true then
  1639. local zone,oldzone = CalculateCurrentZone()
  1640. if zone ~= oldzone and zone ~= zoneplayingmusic and bgm then
  1641. if (zone == nil and (settings.UseGlobalBackgroundMusic == true or settings.MusicOnlyPlaysWithinZones == true)) or zone ~= nil then
  1642. FadeOutSound(bgm)
  1643. return
  1644. end
  1645. elseif zone and bgm == nil then
  1646. PlaySound(SelectRandomMusic(zone["Music"]))
  1647. zoneplayingmusic = zone
  1648. return
  1649. elseif zone == nil and oldzone and settings.MusicOnlyPlaysWithinZones == false and settings.UseGlobalBackgroundMusic == false and bgm == nil then
  1650. PlaySound(SelectRandomMusic(oldzone["Music"]))
  1651. zoneplayingmusic = oldzone
  1652. return
  1653. elseif zoneplayingmusic and settings.MusicOnlyPlaysWithinZones == false and settings.UseGlobalBackgroundMusic == false and bgm == nil then
  1654. PlaySound(SelectRandomMusic(zoneplayingmusic["Music"]))
  1655. return
  1656. elseif settings.UseGlobalBackgroundMusic == true and bgm == nil then
  1657. PlaySound(SelectRandomMusic(music[globali]))
  1658. zoneplayingmusic = nil
  1659. return
  1660. end
  1661. elseif bgm == nil and settings.UseGlobalBackgroundMusic == true then
  1662. PlaySound(SelectRandomMusic(music[globali]))
  1663. return
  1664. end
  1665.  
  1666. if bgm and (settings.UseGlobalBackgroundMusic == true and zoneplayingmusic == nil and #music[globali] > 1) or (zoneplayingmusic and #zoneplayingmusic["Music"] > 1) then
  1667. local length = bgm.TimeLength
  1668. local pos = bgm.TimePosition
  1669. if length ~= 0 and length - pos < FadeoutTime + .5 then
  1670. FadeOutSound(bgm)
  1671. end
  1672. end
  1673. end
  1674.  
  1675. while wait(.5) do
  1676. RunCycle()
  1677. end
  1678.  
  1679.  
  1680. -- Cindering
  1681. -- Twitter: @Cindering_
  1682. end))
  1683. ScreenGui58.Name = "MuteButtonGui"
  1684. ScreenGui58.Parent = LocalScript57
  1685. TextButton59.Name = "Button"
  1686. TextButton59.Parent = ScreenGui58
  1687. TextButton59.Position = UDim2.new(1, -92, 1, -37)
  1688. TextButton59.Size = UDim2.new(0, 90, 0, 35)
  1689. TextButton59.BackgroundColor = BrickColor.new("Institutional white")
  1690. TextButton59.BackgroundColor3 = Color3.new(1, 1, 1)
  1691. TextButton59.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
  1692. TextButton59.Font = Enum.Font.SourceSansBold
  1693. TextButton59.FontSize = Enum.FontSize.Size18
  1694. TextButton59.Text = "Music: ON"
  1695. TextButton59.TextColor = BrickColor.new("Earth blue")
  1696. TextButton59.TextColor3 = Color3.new(0.231373, 0.231373, 0.278431)
  1697. TextButton59.TextSize = 18
  1698. TextButton59.TextStrokeColor3 = Color3.new(0.156863, 0.160784, 0.176471)
  1699. ModuleScript60.Name = "Settings"
  1700. ModuleScript60.Parent = Folder53
  1701. table.insert(cors,sandbox(ModuleScript60,function()
  1702. -- Looking for how exactly to set up your background music? Open the Readme/Instructions script!
  1703.  
  1704.  
  1705. local settings = {}
  1706.  
  1707. settings.UseGlobalBackgroundMusic = true -- If you want to play Global Background Music for everyone in your game, set this to true.
  1708.  
  1709. settings.UseMusicZones = false -- If you are using the Background Music Zones to play specific music in certain areas, set this to true.
  1710.  
  1711. -- You may turn both of these on at once. In that case, zone-specific music will play in the appropriate zones, and global background music will play whenever you're not within any zone.
  1712.  
  1713.  
  1714. settings.DisplayMuteButton = true -- If set to true, there will be a button in the bottom-right corner of the screen allowing players to mute the background music.
  1715.  
  1716. settings.MusicFadeoutTime = 2 -- How long music takes to fade out, in seconds.
  1717.  
  1718. settings.MusicOnlyPlaysWithinZones = false -- (This setting only applies when UseGlobalBackgroundMusic is set to false) If a player walks into an area that's not covered by any music zone, what should happen? If true, music will stop playing. If false, the music from the previous zone will continue to play.
  1719.  
  1720. return settings
  1721.  
  1722. end))
  1723. for i,v in pairs(mas:GetChildren()) do
  1724. v.Parent = script
  1725. pcall(function() v:MakeJoints() end)
  1726. end
  1727. mas:Destroy()
  1728. for i,v in pairs(cors) do
  1729. spawn(function()
  1730. pcall(v)
  1731. end)
  1732. end
Advertisement
Add Comment
Please, Sign In to add comment