How do I update text?

Hello!

I need some help with updating my UI text. What I found is that tostring() is how I update it. But I don’t know how to update my text. A bit of info this is a filter made by Roblox and I’m using it to make a server shout.

Code

-- Script
local function onSetSignText(player, text)
	if text ~= "" then
		-- filter the incoming message and send the filtered message
		local messageObject = getTextObject(text, player.UserId)
		local filteredText = ""
		local success, errorMessage = pcall(function()
			filteredText = getFilteredMessage(messageObject)
		end)
		if success then
			tostring(signLabel.Text)
			signLabel.Text = filteredText
		elseif errorMessage then
			print("Error Filtering message for broadcast")
		end
	end
end

Well, I’m not understanding you correctly here but don’t you set the text right here in the function? Are you asking how to call the function? What exactly are you trying to do in a bit more detail for my small brain so I don’t point you in a wrong direction.

My problem is this bit here

		if success then
			tostring(signLabel.Text)
			signLabel.Text = filteredText
		elseif errorMessage then

I don’t know how to update the text. I think the text won’t update due to it being a script. Since this is made to be a server shout and I want everybody to see the shout. I thought a script would work.

whats your code for when you click the button

This is code from Roblox
Game here Random Text Filtering - Roblox

-- LocalScript

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local screen = playerGui:WaitForChild("ShoutGui")

-- GUI elements for dialog
local frame = screen:WaitForChild("Frame")
local box = frame.Message
local button = frame.Send

-- RemoteEvent to send text to server for filtering and display
local setSignText = ReplicatedStorage:WaitForChild("SetSignText")

-- Called when button is clicked
local function onClick()
	local message = box.Text
	if message ~= "" then
		setSignText:FireServer(message)
		frame.Visible = false
	end
end

button.MouseButton1Click:Connect(onClick)

then you recieve it on the server how

Via a remote event

-- Fired when client sends a request to write on the sign
local function onSetSignText(player, text)
	if text ~= "" then
		-- filter the incoming message and send the filtered message
		local messageObject = getTextObject(text, player.UserId)
		local filteredText = ""
		local success, errorMessage = pcall(function()
			filteredText = getFilteredMessage(messageObject)
		end)
		if success then
			tostring(signLabel.Text)
			signLabel.Text = filteredText
		elseif errorMessage then
			print("Error Filtering message for broadcast")
		end
	end
end

setSignText.OnServerEvent:Connect(onSetSignText) -- Here

you forgot this my king

local function getFilteredMessage(textObject, toPlayerId)
	local filteredMessage
	local success, errorMessage = pcall(function()
		filteredMessage = textObject:GetNonChatStringForUserAsync(toPlayerId)
	end)
	if success then
		return filteredMessage
	elseif errorMessage then
		print("Error filtering message",errorMessage)
	end
	return false
end