Rain System Particles not Working

Hello developers,

  1. What do I want to achieve? I want the rain particle to enable when the “IsRaining” value is set to true and vice versa when it is set to false

  2. What is the issue? The particle is not enabling even though the “IsRaining” value is changing

  3. What solutions have I’ve tried so far? I tried setting the value by using Roblox’s Attribute system, but that didn’t work, I also tried changing the transparency of the particle instead of the “Enabled” value, but that also didn’t work. Finally, I have looked on the Devforum and searched my issue on the web.

I’m making a rain system. I have a “main” script within StarterPlayerScripts (and it is a local script). I also have the part I’m cloning above the player’s head (which this part contains the particle emitter) within ReplicatedStorage. There is a script within Workspace which changes the “IsRaining” value (which is a bool value and this boolValue is in the Workspace too). As I mentioned above, everything is working but the particle for the rain is not enabling/disabling.

Script:

local player = game.Players.LocalPlayer
local part = game.ReplicatedStorage:WaitForChild("RainPart")
local weld = Instance.new("Weld")
local rainVal = game.Workspace:WaitForChild("IsRaining")


local partClone = part:Clone()
function insertRainPart()
	local char = player.Character
	partClone.Parent = char
	partClone.Anchored = false
	partClone.CanCollide = false
	partClone.Name = "RainPartCLONE"
	weld.Parent = partClone
	weld.Part1 =  partClone
	weld.Part0 = char.HumanoidRootPart
	weld.C1 = CFrame.new(0,-30,5)
end

wait(1)
insertRainPart()

player.Character.Humanoid.Died:Connect(function()
	wait(6)
	insertRainPart()
end)

while task.wait(1) do
	if rainVal == true then
		partClone.RainEmitter.Enabled = true
	else
		partClone.RainEmitter.Enabled = false
	end
end

If anyone knows how to fix this it would be great help and thanks (and sorry if this is an easy solution)!

IDK what teh problem is but just a tip, don’t do:

if rainVal == true then

Instead do:

if rainVal then

It’ll automatically check if it’s true, if you put a not before it’ll check if it’s false

You should use Remote Events to handle server to client and vice versa communication. Using values (like BoolValue) isn’t reliable and may cause errors like this one.

How does one go about that (I’m not asking for a script, just an explaination, I’m sort of a new scripter)

Basically a RemoteEvent sends info from the Client to the Server and viceversa, I’ll leva e the Documentation linke here

I can write you some code by heart

serverscript: (remote event to tell client if RainEmitter.Enabled should be “true” or “false”

local RemoteE = game.ReplicatedStorage.RemoteEvent
RemoteE.FireAllClients(true) --enable
--or
RemoteE.FireAllClients(false) --disable

localscript (receive from server to know if should be enabled or not)

local RemoteE = game.ReplicatedStorage.RemoteEvent
RemoteE.OnClientEvent(function(msg) 
   if msg == true then
      print("enabled!")
   elseif msg == false then
      print("disabled")
   else warn("error!)
   end
end)

edit: I’m not 100% sure if it’s bug-less, perhaps you have to check the “ends”

here’s some documentation: