Custom Sign Not Working

I have this gui where players can customize the sign text of their vehicle. The problem? It makes the text blank instead of change it to what’s in the TextBox.
I have all the remote events and everything working, I know because if I use TextBox.PlaceholderText it changes the sign to the PlaceholderText but not when I use TextBox.Text
Thanks for any help! :hugs:

LOCAL SCRIPT

local player = game.Players.LocalPlayer

local replicatedStorage = game:GetService('ReplicatedStorage')
local Event = game.ReplicatedStorage.RemoteEvents.VehicleSystem.EditSign

local Frame = script.Parent
local Send = Frame.Done
local TextBoxButton = Frame.Button
local TextBox = Frame.TextBox
local Remaining = Frame.LetterCountBar.Remaining.LetterCount
local RemainingBar = Frame.LetterCountBar.Remaining

local maxCharacters = 18

local debounce = false

TextBoxButton.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		TextBox:CaptureFocus()
		wait(0.01) debounce = false
	end
end)

TextBox:GetPropertyChangedSignal('Text'):Connect(function() -- Ignore, just for a bar that shows how many characters the player is allowed
	TextBox.Text = string.sub(TextBox.Text, 1, maxCharacters)
	Remaining.Text = (maxCharacters - #TextBox.Text)
	RemainingBar.Size = UDim2.new(#TextBox.Text/18, 0, 0, 10)
end)

Send.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		if TextBox.Text ~= '' then
			Event:FireServer(TextBox)
			TextBox.Text = ''
		end
		wait(0.01) debounce = false
	end
end)

SERVER SCRIPT

local Event = game.ReplicatedStorage.RemoteEvents.VehicleSystem.EditSign
local TextService = game:GetService("TextService")

Event.OnServerEvent:Connect(function(player,TextBox)
	workspace.Vehicles[player.Name].TextSign.SurfaceGui.TextLabel.Text = TextBox.Text -- *The vehicle is named after the player who owns it*
end)

Pass the value of TextBox.Text instead of the TextBox itself. You are changing the value of .Text on the client so reading it from the server will yield it’s “unchanged” value because the change of the .Text property is not replicated.

			Event:FireServer(TextBox.Text)
Event.OnServerEvent:Connect(function(player,Text)
	workspace.Vehicles[player.Name].TextSign.SurfaceGui.TextLabel.Text = Text
end)

Also you must implement text filtering for this code. If you do not then your game will face moderation.

1 Like

Like this??

local Event = game.ReplicatedStorage.RemoteEvents.VehicleSystem.EditSign
local TextService = game:GetService("TextService")

Event.OnServerEvent:Connect(function(player,Text)
	local filteredTextResult = TextService:FilterStringAsync(Text)
	workspace.Vehicles[player.Name].TextSign.SurfaceGui.TextLabel.Text = filteredTextResult
end)

Use GetNonChatStringForBroadcastAsync() instead.
I suggest you just rip the code straight from the article I linked to avoid any confusion.

Check Example 2.

1 Like

Now if I do TextBox.Text it does nothing and if I do TextBox.Placeholder text it makes it blank (This is on the local script sending over to the server)

Ok, I finally fixed it! Thanks everyone for any help :upside_down_face: