Advertisement
Thecodeeasar

Untitled

Oct 1st, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. -- Roblox LocalScript to Continuously Create Random Objects and Teams with Sound Preloading
  2.  
  3. -- Function to preload spooky music
  4. local function preloadSpookyMusic()
  5. local sound = Instance.new("Sound")
  6. sound.SoundId = "rbxassetid://515669032" -- Spooky Scary Skeletons music
  7. sound.Volume = 1
  8. sound.Looped = false
  9. sound.Parent = game.Workspace
  10.  
  11. -- Preload the sound by playing it and stopping immediately
  12. sound:Play()
  13. wait(0.1) -- Wait a short moment to ensure it starts loading
  14. sound:Stop()
  15.  
  16. return sound
  17. end
  18.  
  19. -- Function to delete existing teams
  20. local function deleteExistingTeams()
  21. for _, team in pairs(game.Teams:GetChildren()) do
  22. team:Destroy() -- Deletes each existing team
  23. end
  24. end
  25.  
  26. -- Function to create rainbow teams
  27. local function createRainbowTeams()
  28. local colors = {
  29. Color3.fromRGB(255, 0, 0), -- Red
  30. Color3.fromRGB(255, 127, 0), -- Orange
  31. Color3.fromRGB(255, 255, 0), -- Yellow
  32. Color3.fromRGB(0, 255, 0), -- Green
  33. Color3.fromRGB(0, 0, 255), -- Blue
  34. Color3.fromRGB(75, 0, 130), -- Indigo
  35. Color3.fromRGB(148, 0, 211) -- Violet
  36. }
  37.  
  38. for _, color in pairs(colors) do
  39. local team = Instance.new("Team")
  40. team.Name = "Xu8R messed up the game"
  41. team.TeamColor = BrickColor.new(color)
  42. team.AutoAssignable = true -- Automatically assign players to this team if desired
  43. team.Parent = game.Teams
  44. end
  45. end
  46.  
  47. -- Function to create random objects in the workspace
  48. local function createRandomObjects()
  49. local objectTypes = {"Part", "Sphere", "Wedge", "Cylinder"}
  50.  
  51. for i = 1, 50 do -- Change the number for more or fewer objects
  52. local objectType = objectTypes[math.random(#objectTypes)]
  53. local object
  54.  
  55. if objectType == "Part" then
  56. object = Instance.new("Part")
  57. object.Size = Vector3.new(math.random(1, 10), math.random(1, 10), math.random(1, 10))
  58. object.Position = Vector3.new(math.random(-50, 50), math.random(5, 50), math.random(-50, 50))
  59. object.BrickColor = BrickColor.Random() -- Random color
  60.  
  61. elseif objectType == "Sphere" then
  62. object = Instance.new("Part")
  63. object.Shape = Enum.PartType.Ball
  64. object.Size = Vector3.new(math.random(1, 10), math.random(1, 10), math.random(1, 10))
  65. object.Position = Vector3.new(math.random(-50, 50), math.random(5, 50), math.random(-50, 50))
  66. object.BrickColor = BrickColor.Random()
  67.  
  68. elseif objectType == "Wedge" then
  69. object = Instance.new("WedgePart")
  70. object.Size = Vector3.new(math.random(1, 10), math.random(1, 10), math.random(1, 10))
  71. object.Position = Vector3.new(math.random(-50, 50), math.random(5, 50), math.random(-50, 50))
  72. object.BrickColor = BrickColor.Random()
  73.  
  74. elseif objectType == "Cylinder" then
  75. object = Instance.new("Part")
  76. object.Shape = Enum.PartType.Cylinder
  77. object.Size = Vector3.new(math.random(1, 10), math.random(1, 10), math.random(1, 10))
  78. object.Position = Vector3.new(math.random(-50, 50), math.random(5, 50), math.random(-50, 50))
  79. object.BrickColor = BrickColor.Random()
  80. end
  81.  
  82. if object then
  83. object.Anchored = true -- Prevent falling due to gravity
  84. object.Parent = workspace -- Add the object to the workspace
  85. end
  86. end
  87. end
  88.  
  89. -- Main execution flow (Client-Side)
  90. local spookyMusicSound = preloadSpookyMusic() -- Preload the spooky music
  91.  
  92. while true do
  93. deleteExistingTeams() -- Delete all original teams first
  94. createRainbowTeams() -- Create new rainbow teams with the message
  95. createRandomObjects() -- Create random objects in the workspace
  96.  
  97. spookyMusicSound:Play() -- Play the spooky music each iteration (optional)
  98.  
  99. wait(0.5) -- Wait for half a second before the next iteration.
  100. end
  101.  
  102. print("Chaos unleashed: Xu8R messed up the game with random objects and rainbow teams!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement