What am I doing wrong with this rain script?

The issue with that is that all 3 of those statements have different waits, so he’d probably have to make it wait the longest it would be before rain changes, maybe every 65 seconds the value changes to be safe

Would setting all the waits to the same thing make it work better? (The waits differences aren’t neccessary)

If you want, if you made all of them 60 for example, you could make the wait in the server change the value randomly every 60.1 seconds to make sure it’s randomized before the clients can reference it

1 Like

Like this?

while wait() do

local num = math.random(0,12)

script.Parent.Value = num

wait(60.1)

end

(sorry about formatting)

while true do

local num = math.random(0,12)

script.Parent.Value = num

wait(60.1)

end

I recommend putting the BaseValue itself i nReplicatedStorage, where you put the rain module too, and make the local scripts get that value from ReplicatedStorage and use that

1 Like

The script would still be in the value, correct?

Put the value with the randomized number in ReplicatedStorage, and change that code to reference it and the localscripts to reference it as well

I put a print statement in the script (in the value), but it doesn’t run at all?

while wait() do
	local num = math.random(0,12)
	print(num)
	script.Parent.Value = num
	wait(60.1)
end
LocalScript:
rainmod = require(game.ReplicatedStorage.Rain)
rainmod:Disable()

while wait() do
	local num = game.ReplicatedStorage.Values.RainValue

	if num == 0 then
		rainmod:SetTransparency(0)
		rainmod:SetSpeedRatio(1)
		rainmod:SetIntensityRatio(1)
		rainmod:Enable()
		wait(60)
		rainmod:Disable()
	elseif num == 6 then
		rainmod:SetTransparency(0.8)
		rainmod:SetSpeedRatio(0.4)
		rainmod:SetIntensityRatio(0.4)
		rainmod:Enable()
		wait(60)
		rainmod:Disable()
	elseif num == 12 then
		rainmod:SetTransparency(0.8)
		rainmod:SetSpeedRatio(1)
		rainmod:SetIntensityRatio(0.1)
		rainmod:Enable()
		wait(60)
		rainmod:Disable()
	end
end

Your issue is that if it’s not 0, 6, or 12, it wont rain. So the rain wont happen. Also, change script.Parent.Value to the location of the value itself, so

game.ReplicatedStorage.Values.RainValue.Value = num

Wouldn’t the print statement still run, and print the number? It’s not printing at the moment.

Ohh, where did you put that script? also again, while true do, not while wait() do in this case,

The script is inside the value, should I change it?

Put it in ServerScriptService and do the changes I mentioned

1 Like