More advanced/better way to this script if possible

ServerSideScript:

local function CheckAllPlayersLoaded()
	local playersInGame = 0
	for _, player in pairs(Players:GetPlayers()) do
		if player.CharacterAdded then
			playersInGame = playersInGame + 1
			print("The player who joined the server is:", player.Name)
			if #Players:GetPlayers() == 1 then
				print("Player has been loaded in")
				task.wait(5)
			else
				print("Player has not been loaded in")
			end
		end
	end
end


Players.PlayerAdded:Connect(function(player)
	CheckAllPlayersLoaded()
	if true then
		Blur.Enabled = true
		task.wait(4.3)
		Blur.Enabled = false
	end
end)

Local script:

local waitingMessages = {
	"Waiting",
	"Waiting.",
	"Waiting..",
	"Waiting...",
	"Successfully Loaded!",
}

local function loopWaiting()
	for i, v in ipairs(waitingMessages) do
	task.wait(0.8)
	waitingText.Text = waitingMessages[i]
	end
	waitingText.Visible = false
end

loopWaiting()

I have these 2 scripts that implement a blur effect and waiting text Label. When a player joins, the blur effect is enabled on the serverside for 4.3 seconds. Then on the client side the waiting Textlabel is enabled and displays each message in the waitingMessages table

Is there a more advanced way to doing this. Because I feel like this depends on the connection of the client. If the client is laggy the blur effect can occur to early for them or too late.

I implemented task.wait() so the timings are correct and the blur effect and GUI disappear at the same time

These can get out of sync; The client may not replicate the client script before the server script. Meaning the server could start first. There are other factors that I can think of that can set these 2 scripts out of sync quite easily.


My question is why are you trying to set the blur on the server. With the server script, All clients will recieve this blur effect. Basically whenever someone joins, everyone will be blurred for the 4.3 seconds, since it’s in a server script.

If it were me, I would keep it all client.

If you want the blur to be on join, set the blur right away.

If you want the blur after loading, in a client script do

repeat task.wait() until game:IsLoaded()
--Blur effect here

Also, if you notice that it takes time for the loading screen to show up, and the blur to be applied. Use the service ReplicatedFirst and put all elements of the loading screen in Replicated First. As the name suggests, this is what the clients replicate First when joining the game. Put some lines of code that will change the parents of the elements of the loading screen to the proper places instead

Let me know if you have any questions!

The problem is solved, thank you for the help!

1 Like

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