How do I make a remote function that updates the player's text on the top of their screen

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve something that can update the client’s text label on the top of their screen like in a minigame game.
  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to do it.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes I have, but I could not find any on here or Youtube.

You do not have to give me an entire script, I just want to know how. I know it includes remote events and stuff.

1 Like

I suggest using RemoteEvents instead, because it doesn’t need to return anything to continue on in the script.
Create a RemoteEvent in ReplicatedStorage called “Update”.

Now in a LocalScript in StarterGui you can do this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("Update")
local textLabel = nil -- This is the text label to be updated

-- Bind the event to a function.  The first argument is the text to be set.
event.OnClientEvent:Connect(function(text)
    textLabel.Text = text
end)

Now in a Script where ever you want, you can write this code to fire the event:

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("Update")

local number = 0

-- Every second we add 1 to the number and fire the event,
-- and sending the number to the client, so it can be shown
-- as the provided TextLabel's text.
while true do
    number = number + 1
    
    -- Convert the number to a string and send it off:
    event:FireClient(tostring(number))
    wait(1)
end

If you want some documentation, here you go:

1 Like