Need help with making it rain for all players in a server

Hello there!

I am trying to make it rain for all players in the server.
I would like the rain to be synced for all players from when the rain starts/stops, preferably without messing with things such as the rain attachments based on a player’s camera position.
I am using buildthomas’s plugin, Rain Plugin for the raining script

Since I have “RainScript” setup as the following at the end:

while true do
	wait(math.random(5, 50))
	Rain:Enable()
	Drops.Enabled = true
	wait(math.random(5, 50))
	Rain:Disable()
	Drops.Enabled = false
end
-- "Drops" refers to the local script which controls raindrops.

The rain will play at a random time, but random to a specific player, making different players have rain at different times. I’ve combined the rain with boatbomber’s Screen Rain by making the RainScript enable/disable the local script for the raindrops. I did that by converting the module script in charge of making the raindrops into a local script so it can be enabled/disabled, and putting it in the Rain Script.

Solutions I’ve tried
I’ve tried transferring the script “RainScript”+ to a normal script, but am given the error "RenderStepped event can only be used from local scripts " I’ve also tried making a normal script enable/disable the RainScript for players, which also gave me the same error.

Edit: Another failed solution

Quick update.

I just tried creating a script in ServerScriptService that would enable/disable the local rain scripts in PlayerScripts, but was met with the error code “ServerScriptService.DayCycles.Script:2: attempt to index nil with ‘PlayerScripts’”. Unsure as to why to why it thinks PlayerScripts does not exist. Once again, unsure if I am making beginner mistake and just missing something obvious haha.

local player = game.Players.LocalPlayer
local rainPlay = player.PlayerScripts.RainScript
local dropPlay = rainPlay.Raindrops
-- theres more to this script, but this is the section I got the error code from

Not sure if I’m missing something or making a rookie mistake since I am not very good at scripting, so please bare with me and any questions I may have. Any help is appreciated, thanks!

1 Like

The reason it’s different for each player is because it’s a local script. So a local script starts when the client, the player, joins the game. So this local script only affects that player. To fix this, I recommend removing entirely the local script, and have it all on a script in the server script service. That way, it is the same for everyone at each time.

1 Like

I tried doing this, but was given the error “RenderStepped event can only be used from local scripts”. In the rain module somewhere, I believe it runs this so the rain attachments are moved based on where the camera is moved. (Not 100% sure about that though).

If I were to guess, I would need a script in ServerScriptService that enables/disables rain, but I am not too confident on how I would go about doing that, or whether it would be the correct solution.

1 Like

Yeah well I didn’t see the RenderStepped part from the scripts, but I assume you can either either make the server run the “wait then enable rain and wait and disable it”. But instead, I can offer you to make a boolvalue inside of replicatedstorage, and instead of doing Rain:Enable(). You could do like replicatedstorage.Boolvalue.Value = true. Then your client does a getpropertychangesignal or changed, then it makes it rain, and stops if its false. This would probably work.

1 Like

Actually, just got it solved from someone else on another platform.

The solution was to create a script in ServerScriptService that set an attribute in Lighting to true/false randomly, and have the local script enable/disable based on if the attribute was true/false.

Thanks for your help though! You solution is correct it seems.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.