I am using this rain plugin by builderthomas (Rain Module + Plugin) however with the rain enabled, when the player dies and respawns i get the output flooded with errors saying RainStraight is not a valid member of Part “__RainEmitter”. Has anyone had this before? This is my weather handler script on the server
--[[ INSTRUCTIONS:
To use this script, you must use BuildThomas' Rain Plugin for this to work.
LINK:
Also, put RainScript2.0 in Server Script Storage, and LocalRainScript in StarterPlayerScripts.
StarterPlayerScripts is in StarterPlayer.
Put BoolValue1 into Replicated Storage.
Put RainySky and Sky into ServerStorage.
If you need help with using these scripts, the link will be below
LINK:
]]--
--What does this script do?
--This script will make it so it rains at random times.
local Rain = require(game.ReplicatedStorage:WaitForChild("Rain"))
local X_WEATHER_DECIDER = 1 -- Don't change this
local RAIN_CHANCE = 25 --[[ this number decides the chance per second for it to rain. 3200
for ex. if this number is 25, there will be a 1 in 25 chance every second for it to rain.--]]
local SHORTEST_LENGTH_OF_RAIN = 60 --This is the shortest possible length of rain that can be chosen by RNG in seconds 90
local LONGEST_LENGTH_OF_RAIN = 80 --This is the longest possible length of rain that can be chosen by RNG in seconds 1500
local RAIN_FOG_COLOR = Color3.fromRGB(242, 248, 247) -- This is the fog color during the rain.
local RAIN_FOG_END = 100 --This is distance away from the player where sight is completely obscured.
local originalFogColor = game.Lighting.FogColor --This variable is used for changing the fog color back to normal after the storm.
local RainingEvent = game.ReplicatedStorage:WaitForChild("Raining")
wait(5)
while true do
local weatherDecider = math.random(X_WEATHER_DECIDER, RAIN_CHANCE)
local IsRaining = game:GetService("ReplicatedStorage").IsRaining --This bool value (true or false) tells the local rain script when it should or shouldn't rain.
-- This just shows what number the RNG got. If the number picked is the same as the number in the if statement, something is wrong.
wait(1)
if weatherDecider == 5 then --if RNG gets same number as this, this will trigger the rain. Number in if statement doesn't matter.
local lengthOfRain = math.random(SHORTEST_LENGTH_OF_RAIN, LONGEST_LENGTH_OF_RAIN) --picks random length of rain between SHORTEST_LENGTH_OF_RAIN, LONGEST_LENGTH_OF_RAIN. Go to line 23 and 24 for more info.
print(lengthOfRain)
local howLongRaining = 0 --don't change. used for length of rain timer
RainingEvent:FireAllClients("Start")
Rain:Enable()
IsRaining = true
print("Rain started")
repeat
howLongRaining = howLongRaining + 1 -- adds 1 to howLongRaining every second as a timer
wait(1)
until howLongRaining == lengthOfRain -- timer stops when timer reaches same amount of time in seconds as what RNG chose
RainingEvent:FireAllClients("Stop")
Rain:Disable()
IsRaining = false
print("Rain stopped")
end
end
Here is my script that enables and disables
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local RainEvent = RS:WaitForChild("Raining")
local BindableRain = RS:WaitForChild("RainBindable")
local Weather = RS:WaitForChild("Weather")
local Skies = Weather:WaitForChild("Skies")
local X_WEATHER_DECIDER = 1 -- Don't change this
local RAIN_CHANCE = 25 --[[ this number decides the chance per second for it to rain. 3200
for ex. if this number is 25, there will be a 1 in 25 chance every second for it to rain.--]]
local SHORTEST_LENGTH_OF_RAIN = 10 --This is the shortest possible length of rain that can be chosen by RNG in seconds 90
local LONGEST_LENGTH_OF_RAIN = 20 --This is the longest possible length of rain that can be chosen by RNG in seconds 1500
local RAIN_FOG_COLOR = Color3.fromRGB(242, 248, 247) -- This is the fog color during the rain.
local RAIN_FOG_END = 100 --This is distance away from the player where sight is completely obscured.
local ORIGINAL_SKY = Skies:WaitForChild("Sky") --ORIGINAL_SKY and RAINY_SKY are used for changing skyboxes. Change the last word at the end to the name of your skies you want for when it's clear and rainy.
local RAINY_SKY = Skies:WaitForChild("RainySky")
local originalFogColor = game.Lighting.FogColor --This variable is used for changing the fog color back to normal after the storm.
local function RainFunction(State)
local Rain = require(game.ReplicatedStorage:WaitForChild("Rain"))
if State == "Start" then
if game.Lighting:FindFirstChild("Sky") then
game.Lighting.Sky:Destroy() --Destroys main sky
else
return
end
rainySkyClone = RAINY_SKY:Clone() --Clones the rainy sky and puts it in lighting to change skyboxes
rainySkyClone.Parent = game.Lighting
game.Lighting.FogColor = RAIN_FOG_COLOR --Sets color of fog to RAIN_FOG_COLOR on line 26
game.Lighting.FogEnd = RAIN_FOG_END --Sets distance away from player where fog completely obscures vision to RAIN_FOG_END on line 27
Rain:Enable()
elseif State == "Stop" then
Rain:Disable()
rainySkyClone:Destroy() --Destroys rainy sky since we don't need it for now
local SkyClone = ORIGINAL_SKY:Clone() --Clones main sky and puts it in Lighting to change skybox to main one
SkyClone.Parent = game.Lighting
game.Lighting.FogColor = originalFogColor --Changes fog color back to normal
game.Lighting.FogEnd = 100000 -- Changes FogEnd back to normal
end
end
RainEvent.OnClientEvent:Connect(function(State)
print(State)
RainFunction(State)
end)
BindableRain.Event:Connect(function(State)
print(State)
RainFunction(State)
end)
I have tried to re-enable the rain when you hit play on the main menu using a bindable action as both the rainhandler and menu use localscripts.
Any help would be greatly appreciated