Help getting my rain script to loop i've tried

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 = {, 0);, 0);


local numberKeypoints2 = {, 0);, stormArea);


local RainFx = script.Parent.Rain

local RainLevel = math.random(1,3)

RainFx.Volume = RainLevel

local EndRain = function()


Lighting.Brightness = 2

mist.Enabled = false

water.Enabled = false

Lighting:WaitForChild(“Blur”).Parent = game.ServerStorage

mist.Size =

water.Size =


local P = function(blur)

IsRaining = true

script.Parent.Position =,altitude,script.Parent.Position.Z)



if IsRaining and RainFx.Playing then

blur =“BlurEffect”,Lighting)

blur.Size = RainLevel + 1

Lighting.Brightness = StormCover

mist.Enabled = true

water.Enabled = true

mist.Size =

water.Size =




if Newstorm then


script.Parent.Size = * math.pi,0,stormArea * math.pi)



1 Like

1st of all I’m not a good scripter 2nd of all format your code like this

Like this By doing >

that’s why nobody has pretty much tried to help you with your code but I have 1 Idea on the top put While true do and the bottom you leave as end (sorry for only seeing this)

it’s fine i have moved on i might go and try to fix it later i’m a better scripter now

1 Like

Oh yeah, incase you ever come back to this a note of interest would to NOT use while true do as the person said. Use RunService and bind it to a variable which you can disconnect later to avoid memory leaks

this is not a local script though run service is for local

Oh Ok, I would question why you’re running this through the server but I don’t want to bump something you probably aren’t as interested in anymore so I’ll be quiet from now