Weather/Biome Client not updating?

Hi, so i have a weather/biome script kinda similar to the one in Sol's RNG but I have issues within.

The Issues: When there are two players in the game, the script only updates for the player who first joined the game. Also, it only runs when there are two players in the game? Not sure why.

Server Sided Script (The important parts)
game.Players.PlayerAdded:Connect(function(plr)
	if plr then
		while true do
			task.wait(1)
			local newState
			repeat
				newState = weatherTable[math.random(1, #weatherTable)]
			until lastState ~= newState

			lastState = newState
			print("LastState: " .. lastState)
			print("Newstate:" .. newState)

			if newState == "Snowy" then
				biomeEvent:FireClient(player, newState, SnowWAIT)
				handleWeatherState(newState)
			elseif newState == "Windy" then
				biomeEvent:FireClient(player, newState, WindyWAIT)
				handleWeatherState(newState)
			elseif newState == "Rainy" then
				biomeEvent:FireClient(player, newState, RainWAIT)
				handleWeatherState(newState)
			elseif newState == "Natural" then
				biomeEvent:FireClient(player, newState, NaturalWAIT)
				handleWeatherState(newState)
			end
		end
	end

	
end)
Client Side Script (Biome Text Handler)


BiomeEvent.OnClientEvent:Connect(function(state, waitTIME)
	print("Wait TIME:", waitTIME, " | State:", state)
	--print(state)
	if state == "Snowy" then
		tweenIN:Play()
		biomeText.Text = "Biome: " .. "Snowy"
		local ohmg = ezVisuals.new(biomeText, "IceStroke", 0.3, 2)
		wait(waitTIME)
		tweenOUT:Play()
		ohmg:Destroy()
	elseif state == "Natural" then
		tweenIN:Play()
		biomeText.Text = "Biome: " .. "Natural"
		local gyat = ezVisuals.new(biomeText, "GreenOutline", 30, 2)
		wait(waitTIME)
		tweenOUT:Play()
		gyat:Destroy()
	elseif state == "Windy" then
		tweenIN:Play()
		windyEvent:FireServer(plr)
		biomeText.Text = "Biome: " .. "Windy"
		local WindyEffect = ezVisuals.new(biomeText, "WaveStroke", 0.55, 2, false, Color3.fromRGB(126, 221, 230));
		wait(waitTIME)
		tweenOUT:Play()
		WindyEffect:Destroy()
	elseif state == "Rainy" then
		tweenIN:Play()
		biomeText.Text = "Biome: " .. "Rainy"
		rainevent:Fire(plr, state, waitTIME)
		local rizz = ezVisuals.new(biomeText, "GhostStroke", 0.6, 1.5)
		wait(waitTIME)
		tweenOUT:Play()
		rizz:Destroy()
	end

end)

(my phone joined first)

There are also no known errors in the output window and the weathers run fine, it’s just how its handled in between two players. Any help would be highly appreciated. Thanks!

2 Likes

this happens because the while wait loop yields the function for everything else, you could bypass this by putting the while wait loop inside a thread by using task.spawn or coroutine.wrap

1 Like

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