Stop A PlayerScript then Start it?

I have a rain LocalScript in StarterPlayerScripts. I want it to run randomly and stop randomly. But I don’t know if I can Stop a script after it has been run and if its a PlayerScript. What can I do? I tried using Disabled but it doesn’t work.

You can have a separate LocalScript toggle the rain LocalScript’s Disabled.

but how since the Rain is in starterPlayerscripts

There is for sure a better way to do this but I can’t think of one right now so test if this works.

local RainState = script.RainState -- BoolValue under script, name whatever you want but make sure to change the name you're using here.

couroutine.wrap(function()
while wait(math.random(60,120)) do -- change to the random times you want
   local Random = math.random(1,2)
      if Random == 1 then
         RainState.Value = true
      elseif Random == 2 then
         RainState.Value = false
      end
   end
end()

RainState.Changed:Connect(function(NewValue)
   if NewValue == true then
      -- make rain happen
   elseif NewValue == false then
      -- make rain stop
   end
end)

Break the script when you want the rain to stop.
Edit: made a script to show what I mean. I can guarantee it might not work because I threw it together in one minute

local rainState = false
local rainCooldown = 60

function rain()
	if not rainState then
		rainState = true
		wait(60)
		rainState = false
	end
end

while wait(1) do
	rainCooldown = rainCooldown - 1
	if rainCooldown < 0 then
		rain()
		break
	end
end