Show local text on workspace?

Hi devs , i wanted to know if its possible to show in local a text from a billboardGui that is in the Workspace ?

image

-Tnks

2 Likes

If I understand your question correctly, you can either directly edit the text from a script placed somewhere in the workspace with RunContext set to Client, or use a localscript placed in starterplayerscripts that directly edits the text from there.

1 Like

Yep exactly. Actually i have put a local script in the billboardgui “0s”.

2 Likes

To set the text of a TextLabel under a BillboardGui locally, all you need to do is set the text from a LocalScript. In this case, you’re likely saving player times in a datastore, so you will need to pass this data to the client first. To do this, you can create a RemoteEvent and run RemoteEvent:FireClient(player, bestTime) (with the arguments pointing to the variables for the player and their best time). In a LocalScript, you can receive this data:

Path.To.RemoteEvent.OnClientEvent:Connect(function(bestTime)
	Path.To.BillboardGui.TextLabel.Text = bestTime .. "s"
end)
1 Like

Again if I understand this correctly, change that script you already have from a localscript to a serverscript but with RunContext in it’s properties set to Client.

1 Like

Actually it doesn’t change anything by doing that cause , i already have a local script that should update and show the timer.

local Player = game.Players.LocalPlayer

local checkPlayer = Player.Data:FindFirstChild("ParkourTimer")
local DisplayTime = script.Parent

local Event = game.ReplicatedStorage:FindFirstChild("OwnTimerParkourEvent")

while true do
	task.wait(15)
	checkPlayer.Value = ""..DisplayTime.Text.."s"
end

But it doesn’t change and it only display “0s”

1 Like

Try doing:

local Player = game.Players.LocalPlayer

local checkPlayer = Player.Data:FindFirstChild("ParkourTimer")
local DisplayTime = script.Parent

local Event = game.ReplicatedStorage:FindFirstChild("OwnTimerParkourEvent")

while true do
	task.wait(15)
	DisplayTime.Text = ""..checkPlayer.Value.."s"
end
2 Likes

Since it worked for you @Tacca_BioX, I’d also recommend changing the portion of your code that controls when the text gets set. Instead of creating a loop that runs every 15 seconds and sets the text, we can instead use the event called Changed which exists on value instances, such as StringValues, NumberValues, IntValues, etc. This isn’t just a better practice, but it’ll also update the value as soon as it’s changed, rather than having to wait up to 15 seconds. In this case, we can change the code to this:

local Player = game.Players.LocalPlayer

local checkPlayer = Player.Data:FindFirstChild("ParkourTimer")
local DisplayTime = script.Parent

local Event = game.ReplicatedStorage:FindFirstChild("OwnTimerParkourEvent")

checkPlayer.Changed:Connect(function()
	DisplayTime.Text = ""..checkPlayer.Value.."s"
end)

This essentially listens for whenever checkPlayer.Value is changed. Whenever it changes, it calls the function that we passed into Connect(). So in this case, whenever the value is changed, it’ll call the function that updates our text.

1 Like

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