Billboard GUI not replicating on other clients

I made a simple UI script that let’s you choose an overhead tag for your character, however, this only happens in the client and no one other than you is able to see it.

I thought switching from a LocalScript to a normal Script would solve it, but instead it breaks the whole thing; I’ve searched about it and found you need to use a RemoteEvent/RemoteFunction, the problem is, I don’t know how and have tried too many times without success :confused:

I’d appreciate if someone could teach me what I’m doing wrong…

This Script is located in ServerScriptService:

local ServerStorage = game:GetService("ServerStorage")

local Overhead = ServerStorage:WaitForChild("Overhead")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		local Clone = Overhead:Clone()
		Clone.Parent = character.Head
		Clone.Label.Text = player.Name
		
	end)
end)

This LocalScript is located inside StarterGui > ScreenGui > Frame > TextButton (inside each of the buttons) [I’d appreciate if someone can tell me if this is bad practice and if there’s another way around]:

local Players = game:GetService("Players")

local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
local Button = script.Parent

local DisplayText = script.Parent.Text
local TXT_COLOR = script.Parent.BackgroundColor3
--\\===============================================//--

local function ButtonPress()
	local TextLabel = Character.Head.Overhead.Label
	TextLabel.Text = DisplayText
	TextLabel.TextColor3 = TXT_COLOR
	TextLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
	TextLabel.TextStrokeTransparency = 0.25
end

Button.Activated:Connect(ButtonPress)

The server should initiate the changes so other clients can see the changes as well. LocalScripts only impact the client itself. The server should handle things where replication is important.

You could use a RemoteEvent to pass data to the server to update the player’s name tag.

--//client code

local updateTagRemote = game.ReplicatedStorage:WaitForChild("NameOfRemote")

local function ButtonPress()
updateTagRemote:FireServer(DisplayText)
end

And then in your server code:

game.ReplicatedStorage.UpdateTagRemote.OnServerEvent:Connect(function(player, tagText)
--//update the player's tag in here with the specified tagText
end)

Also note since the client is able to pass input text to the server, it’s required to use text filtering so bad stuff doesn’t appear globally in your game.

local function filterString(tagText, playerWhoSent)
local filtered;
pcall(function()
filtered = game:GetService("Chat"):FilterStringForBroadcast(tagText, playerWhoSent)
end)

if not filtered then
warn("filtration failed")
else
return filtered
end
end
1 Like

You’re not setting the Adornee to the head. This probably isn’t your problem, but it still is good practice.

1 Like

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