Global billboard appear when player typing

I currently am just using this code to adornee a chat bubble to a players character and it works well on your client but not server side, so my thought was to fire a RemoteEvent to the server and then the server fires to all clients the player whose talking and then someone the client would pick it up and adornee a chat billboard to that character. Problem I fear with that is latency. Client-Server-Client communication can sometimes take 2-3 seconds, and the message could have been sent before then.

local Players = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local HUD = script.Parent

local function TextBoxFocused(textBox)
	if textBox.Name ~= 'ChatBar' then return end
	
	HUD.Adornee = Character
end

local function TextBoxFocusReleased(textBox)
	if textBox.Name ~= 'ChatBar' then return end
	
	HUD.Adornee = nil
end

UserInputService.TextBoxFocused:Connect(TextBoxFocused)
UserInputService.TextBoxFocusReleased:Connect(TextBoxFocusReleased)

Is the code not working or are you trying to ask if a remote event would work in this situation?

Client to Server to Client events won’t take 2 to 3 seconds unless your system is under very heavy load.

Ye it works for client, but I want it to be shown for all players

I think you could just use the remote event as is and have no problem whatsoever. If there is latency then it’d just be the players ping I think and not the remote event.

You should fire the server to set the adornee rather than the client so that it’s shown to everyone.

Well I have to go Client fires server, then server FireAllClients() as server can’t on its own pick up when a player is typing

You can fire from the client to the server when the player starts typing and adorn it though.

Ye I can adornee it from the client, but I have to use FireAllClients so everyone can see it. Otherwise it only shows up on my screen

That’s reasonable, no need to worry. The Roblox chat bubble system uses a similar setup.

Even it you use the chatbox it will have some latency; latency is inevitable. There really isn’t another way to go around this.

Do you get what I’m saying though. Instead of setting the adornee on the client, just fire a remote event to the server saying to adorn it, then have it change it on the server, so it’s a global change that everyone sees.

That’s typically how you would handle things in this situation.
It’s also the same way I did it when I made my own custom chat that said when people were typing.

Wait you can Adornee from the server? I didn’t think the server could access PlayerGui?

If you swap it from PlayerGui, and have it as a child of the object you’re adorning it to, you can access it with the server and set the adornee globally. This is how games make NPC bubbles above heads like the example below from duckie simulator.

Duckie Simulator NPC Bubble - tob777

image

1 Like