Help with giving text to textlabel

i have problem i cannot set text of textlabel to what i need(script is regular and located in ServerScriptService)

local id = game.StarterGui.ScreenGui.ID
local number = math.random(1, 100000000)
id.Text = tostring(number)

You can’t modify player’s GUI on the server. You would need to put your script in a LocalScript and use RemoteEvents.

can describe more detailed what i need to do i not master with remote events

You can read the docs. I believe that there’s enough info on RemoteEvents/RemoteFunctions.

Hi! Your id variable is a reference to StarterGui folder. It’s just contain gui, that will be replicated to Player.

And if you change text of id in this folder, this it won’t be visible for any player.

To change actual player gui you need to get every player joined to server and get their PlayerGui:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	local id = Player.PlayerGui:WaitForChild("ScreenGui").ID
	local number = math.random(1, 100000000)
	id.Text = tostring(number)
end)
1 Like

Hm, I thought ScreenGui doesn’t replicate from server to clients.

what type of script is it and where it located?

Server script in serverscriptservice

And as @GulgPlayer said, if you you don’t want to use this “id” value at server, then will be better to assign it locally

1 Like

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