Remote event delay?

So recently I created an “alert gui” of sorts for my admin panel, basically it has a textbox and when you type something then click another button a gui with that exact message will show up on everyones screen but there is a delay with the guis appearing on everyones screen, this is all done from the starter gui including remote event and local and serverscript and I do not want to change this since the admin panel should be able to be put in multiple games with minimal struggle.

1 Like

There are 2 possible causes for this delay:

  1. To alert everyone, the message must come from the admin to the server so that it can send it out to all the players. Unfortunately, this client-server-client delay is impossible to avoid.

  2. Use of ScreenGui.Enabled property. When a GUI is not enabled, its content doesn’t load and does so instead when it’s first enabled. Due to this, it’s usually best to wrap all the content of the GUI in a fullscreen frame and set its Visible property to false, as opposed to disabling the GUI itself. After that, you can just manipulate the Visible property of the frame instead of the GUI’s Enabled property.

since the gui only includes a textlabel its just blank until the text is put in, so enabled is not on and visible is on. Also I have seen this exact concept done before so I’m not sure what this issue is…

How long is the delay? As @poly3rd said, it could just be ping which is unavoidable, but that delay shouldn’t be so long to be very noticeable. If it’s a long delay, it will be something wrong with your code.

Keep in mind that all user-entered text that gets broadcast to players has to go through roblox’s chat filters, and you have to write the code for that. Otherwise, any game with this system is going to get shut down for having unfiltered text the first time someone broadcasts something inappropriate. Text filtering is pretty fast, but it does call out to a webservice and it’s rate limited someone, so if a lot of people are using chat, it could impact the processing time of your admin broadcasts too.

so basically the delay is almost as though it goes from player to player and by the way the text uses a tween to appear and disappear so I’m just now thinking that since I’m using a for loop to go through all the players it might be putting that wait between putting the gui in all the peoples player guis…

can my game still get shut down even if its only for admin use? and also could you send me a script to filter the text imputted

Sending the code would help us to help you!

I will sorry, I was in a rush when I posted that, here.

local event = script.Parent.AlertEvent

event.OnServerEvent:Connect(function(player, textfromlscript)
	for i,v in pairs(game.Players:GetChildren()) do
			local clone = script.Parent.CloneUI:Clone()

			local function typewrite(object, text, length)
				for i = 1,#text,1 do
					object.Text = string.sub(text,1,i)

					wait(length)
				end
			end

			clone.Parent = v.PlayerGui

			typewrite(clone.ALERTTEXT, textfromlscript, 0.062)
			wait(3)
			local tweenservice = game:GetService("TweenService")
			local tweeninfo = TweenInfo.new(
				0.2, -- time
				Enum.EasingStyle.Linear, -- easing style
				Enum.EasingDirection.Out, -- easing direction
				0, -- repeat count
				false,  --reverse
				0 -- delay
			)

			local tween = tweenservice:Create(clone.ALERTTEXT, tweeninfo, {TextTransparency = 1})
			tween:Play()
			wait(0.2)
		    clone:Destroy()
		
	end
end)

The code is being blocked by your wait calls.
You can wrap your code inside the for loop with a task.spawn

local event = script.Parent.AlertEvent

event.OnServerEvent:Connect(function(player, textfromlscript)
	for i,v in pairs(game.Players:GetChildren()) do
		task.spawn(function()
			local clone = script.Parent.CloneUI:Clone()

			local function typewrite(object, text, length)
				for i = 1,#text,1 do
					object.Text = string.sub(text,1,i)

					wait(length)
				end
			end

			clone.Parent = v.PlayerGui

			typewrite(clone.ALERTTEXT, textfromlscript, 0.062)
			wait(3)
			local tweenservice = game:GetService("TweenService")
			local tweeninfo = TweenInfo.new(
				0.2, -- time
				Enum.EasingStyle.Linear, -- easing style
				Enum.EasingDirection.Out, -- easing direction
				0, -- repeat count
				false,  --reverse
				0 -- delay
			)

			local tween = tweenservice:Create(clone.ALERTTEXT, tweeninfo, {TextTransparency = 1})
			tween:Play()
			wait(0.2)
		    clone:Destroy()
		end)
	end
end)
1 Like

wow thank you so much! I thought this would never work! Thanks so much! :slight_smile:

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