Still have questions? Join our Discord server and get real time help.
2

# Why does the text in a ScreenGUI not change but it prints that it has changed?

Edited 7 months ago

I wrote a code to change the text of the ScreenGui according to the text on a SurfaceGui but it doesn't work

local buttonLeft = game.Workspace.Entries.LeftEnter --Part in the workspace
local CounterLeft = game.Workspace.Counters.LeftCounter.SurfaceGui.Count
local GuiCount = game:GetService("StarterGui").TruckEntered.PeopleTruck.PeopleNumber --textbox of the ScreenGui

if leftValue == true then --finding out if there is a vehicle on the left road
local debounce = true
buttonLeft.Touched:Connect(function(plr)
if plr.Parent:FindFirstChild("Humanoid") then
if debounce == true then
LeftCountVal.Value = LeftCountVal.Value +1 --Value goes up
debounce = false
print(GuiCount.Text) -- prints "0"
CounterLeft.Text = LeftCountVal.Value
GuiCount.Text = CounterLeft.Text --text stays as 0
print(GuiCount.Text) --prints"1"
wait(0.5)
debounce = true
elseif debounce == false then
LeftCountVal.Value = LeftCountVal.Value
end
end
end)
end


The text on the ScreenGui stays as 0

The text that is printed goes up to 1

Now i changed it a little and an error pops up saying

18:38:26.094 - GetPlayerFromCharacter is not a valid member of Model

This is the new script

if leftValue == true then
local debounce = true
buttonLeft.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
if debounce == true then
LeftCountVal.Value = LeftCountVal.Value +1
debounce = false
local player = hit.Parent:GetPlayerFromCharacter()
player.PlayerGui.TruckEntered.PeopleTruck.PeopleNumber = LeftCountVal.Value
CounterLeft.Text = LeftCountVal.Value
wait(0.5)
debounce = true
elseif debounce == false then
LeftCountVal.Value = LeftCountVal.Value
end
end
end)
end


Btw this is in ServerScriptService What is the problem here?

0
You're altering the StarterGui, which has no affect on the player's screen. You have to change it through the player's PlayerGui. killerbrenden 1435 — 7mo
0
This is a local script right? iiConstable_Subwayx 130 — 7mo

4

This is because you are trying to edit the StarterGui version of the UI.

If you edit anything in the StarterGui, it won't reflect the changes til you reset or move it to the player gui. That's why it's called the StarterGui.

To fix this, make the change to the players PlayerGui.

If this is a server script, it'll be a little tricky to get access to the players GUI but not impossible. If this script is a local, it's very easy.

0
So, how do i put the Gui in PlayerGui? kingblaze_1000 310 — 7mo
0
Do i Clone it into the player Gui? kingblaze_1000 310 — 7mo
1
All guis in starter gui are cloned into player gui automatically when the player joins. it is located game.Players.playername.PlayerGui. Modify it from there proqrammed 285 — 7mo
1
I agree with Proq, constantly cloning the ui in startergui to playergui would get annoying and not needed. Just get the plrs playergui and modify the gui from there. You'll save a lot of time. DeveloperSolo 355 — 7mo