So i have been working on this rain system script for a while it works perfectly fine it just happens once and then doesn’t loop I’m not looking for somebody to rewrite the entire code just help me with the existing code my goal is that it’s not looping it only happens once also thing to know i am a pretty experienced coder but i still cant figure it out
The code
local MaxRangeStuds = math.random(120,2500)
local stormArea = math.random(60,MaxRangeStuds)
local LowestAlt = 20
local altitude = 10/stormArea + math.random(LowestAlt,math.random(100,LowestAlt * math.random(5,20)))
local RainDelay = math.random(math.random(1,10),150)
local StormCover = 0.76
local Lighting = game.Lighting
local mist = script.Parent.mist
local water = script.Parent.water
local Newstorm = true
local IsRaining = false
local IsThunder = false
local numberKeypoints1 = {
NumberSequenceKeypoint.new(0, 0);
NumberSequenceKeypoint.new(0, 0);
}
local numberKeypoints2 = {
NumberSequenceKeypoint.new(0, 0);
NumberSequenceKeypoint.new(1, stormArea);
}
local RainFx = script.Parent.Rain
local RainLevel = math.random(1,3)
RainFx.Volume = RainLevel
local EndRain = function()
RainFx:Pause()
Lighting.Brightness = 2
mist.Enabled = false
water.Enabled = false
Lighting:WaitForChild(“Blur”).Parent = game.ServerStorage
mist.Size = NumberSequence.new(numberKeypoints1)
water.Size = NumberSequence.new(numberKeypoints1)
end
local P = function(blur)
IsRaining = true
script.Parent.Position = Vector3.new(script.Parent.Position.X,altitude,script.Parent.Position.Z)
task.wait(RainDelay)
RainFx:Play()
if IsRaining and RainFx.Playing then
blur = Instance.new(“BlurEffect”,Lighting)
blur.Size = RainLevel + 1
Lighting.Brightness = StormCover
mist.Enabled = true
water.Enabled = true
mist.Size = NumberSequence.new(numberKeypoints2)
water.Size = NumberSequence.new(numberKeypoints2)
RainFx.DidLoop:Connect(EndRain)
end
end
if Newstorm then
print(RainDelay)
script.Parent.Size = Vector3.new(stormArea * math.pi,0,stormArea * math.pi)
P()
end