It’s a rain script but for some reason the audio is really buggy and sounds so weird. Any clue why it’s doing this?:
-- Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
-- Starter Part --
local starterPart = Workspace:WaitForChild("StarterPart2")
-- Configuration --
local sizeX = 100 -- Size of the grid on X-axis (100 studs)
local sizeZ = 100 -- Size of the grid on Z-axis (100 studs)
local rainHeight = starterPart.Position.Y -- Set to the Y position of StarterPart2
local loadedPositions = {}
-- Rain Generator --
local rainGenerator = Workspace:WaitForChild("RainGenerator")
-- Function to manage particle and sound cycles
local function manageRainCycle(emitter, sound)
task.spawn(function()
while true do
-- Enable particle emission and set sound volume to 1
emitter.Enabled = true
sound.Volume = 1
if not sound.IsPlaying then
sound:Play() -- Ensure the sound is playing
end
task.wait(10) -- Active for 10 seconds
-- Disable particle emission and set sound volume to 0
emitter.Enabled = false
sound.Volume = 0
task.wait(10) -- Inactive for 10 seconds
end
end)
end
-- Generate Rain Generator Model --
local function generateRainGeneratorModel(x, z)
local position = Vector3.new(x * sizeX, rainHeight, z * sizeZ)
-- Clone the RainGenerator
local clone = rainGenerator:Clone()
clone.Parent = Workspace
clone.Transparency = 0 -- Make it visible
clone.Position = position
-- Find the existing ParticleEmitter in the RainGenerator
local emitter = clone:FindFirstChildOfClass("ParticleEmitter")
if emitter then
-- Add sound to the RainGenerator
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9112854625" -- Assign the sound ID
sound.Looped = true -- Sound will loop continuously
sound.Volume = 0 -- Start with the sound muted
sound.Parent = clone -- Parent the sound to the RainGenerator
-- Start the synchronized rain cycle
manageRainCycle(emitter, sound)
end
end
-- Generate Rain Grid --
local function generateRainGrid()
for z = -25, 25 do -- Adjust range to match the grid size (50x50 grid)
for x = -25, 25 do
local key = tostring(x) .. "_" .. tostring(z)
if not loadedPositions[key] then
generateRainGeneratorModel(x, z)
loadedPositions[key] = true
end
end
end
end
-- Start Generating the Rain Grid --
generateRainGrid()
Any Ideas? Thanks!