Textlabel not updating when it clearly should

Everything is run from Client side [There are no Serverscripts in the entire game].
The properties tab clearly show that the value should be 2, but the label displays 3.
I have no clue why this is happening, perhaps an engine bug?

(And yes, the label in the properties is the label highlighted in blue)

If anyone have any ideas about what is happening, please tell me!

1 Like

2 things

1.
could you provide your script so I can see if there are any errors (or you could look in the output tab if you haven’t)

2.
Im assuming you know this, but local scripts can’t run in workspace or server script service, if that is where it is located

2 Likes

This is most definitely not the cause of an error, even if I would to get one, since the properties tab states that the label should be a 2

Also, sidenote: When I click on the UIElement again, it magicaly updates to a 2

1 Like

could I see your script?

ignore, need to make reply 30 letters long

The video shows that the label just magicaly updates later but the properties are constantly at 6

Again, I have know way of knowing what the issue is if I can’t see your script… also, in your properties tab it doesn’t say the text is changing, which confuses me even more

The properties show 6, the label shows 7, then magicaly the label shows 6

Script that updates TextLabel, fired from Client:
image

Well first, it looks like the term self is already used by Roblox but idk if that’s a problem, but also, are you calling this when your amount of ammo changes or every frame, because if it were me I would use render stepped (but that’s just an opinion).

If that’s not the problem, try checking if any other scripts are interfering, other wise it may be an engine bug and your out of luck.

Feel like it is just a studio bug, as you said the text was 2 and it display 3 wich isn’t normal.

self is used since code is fired from a module script that was required from a Local Script

Function is fired everytime the gun is fired and ammo is deducted

No other scripts have refrences to the Ammo frame

According to all the print() lines and the properties tab the labels text is changed but it is not showing on the label

I would still double check, but if it is a bug, good luck.

I don’t know if I should mark this as the solution but I think that you are correct

I’m not sure too, but after thinking about multiple reasons of why it could do it, i didn’t understand why.

Is it a FPS drop ? maybe, not sure if it can do a delay between the text change and the Gui display.

Are you updating it on server side ? no, as i saw your script and you said it is in client side, and i’m not sure if it also can do a delay between both.

Is the ammo value is at like 6.999999 and the text displayed automaticaly rounded it to 7 ? idk, it is a string so it shouldn’t, and if you’re using a intvalue then there can’t be a decimal number.

It is a weird bug i never saw, so yeah you could maybe close this topic and report it in #bug-reports:engine-bugs or #bug-reports:studio-bugs

Could you please show what the variable Frame refers to? Additionally, you could use print(Frame:GetFullName()) in your code.

Also, is there an children inside of this TextLabel? Can you reproduce this error when testing in-game vs. in-studio? Provide a link to a place so that I can help further investigate this issue, if possible.

Look at the video above, Self.Frame is the frame named “GunTemplate” which contain all text information about the gun, and yes the text have childrens like a UiStroke but i don’t think it have something to do with this bug.

Oh, I did not see the explorer on the left in that video, my bad. Kudos to you for pointing that out. However, I highly doubt this is a studio bug. My assumption leads me to believe it is changing the wrong TextLabel’s properties, or that there is some other factor preventing it from updating.

As you can see in his code, he/she is getting the right Text Object (AmmoInMag) and changing the right Propertie (.Text).

Frame:FindFirstChild("AmmoInMag").Text = tostring(Weapon.AmmoInMag)

After doing that, the text property in this Text Object is changing correctly and instantly like it should, but the bug is that once the text changed, there is a delay for it to be displayed into the current Gui, like the text is “6” and it display “7” then it wait 3sec to display “6”… it can be nothing else than a small studio bug.

It exactly same as if you are doing this

script.Parent.Text = "hello" --TextGui display "hello"

Capture1

task.wait(1)
script.Parent.Text = "TheTextHasChanged" --TextGui still display "hello"

Capture1

task.wait(3)

Capture2

Trust but verify my friend. I still do not think this is a studio bug, but it would not hurt to restart studio by closing it and re-opening it @imlusman.

I have tried to reproduce the error with the same hierarchy. I also updated the TextLabel the same way OP did, and it always updates instantly.

Here is the code (and hierarchy) that I used in my testing environment:

LocalScript in StarterPlayer → StarterPlayerScripts:

-- Client essentials
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- Services
local ContextActionService = game:GetService("ContextActionService")

-- Variables
local mainGui = playerGui:WaitForChild("Main")
local frame = mainGui:WaitForChild("GunTemplate")

local ammo = 30

-- Functions
local function updateAmmoDisplay()
	print("Current text:", frame.AmmoInMag.Text)
	print("Ammo variable:", ammo)
	
	frame.AmmoInMag.Text = tostring(ammo)
	
	print("Updated ammo text:", frame.AmmoInMag.Text)
end

local function decreaseAmmo(actionName: string, inputState: Enum.UserInputState)
	if inputState ~= Enum.UserInputState.Begin then
		return
	end
	
	ammo -= 1
	updateAmmoDisplay()
end

-- For testing:
ContextActionService:BindAction("DecreaseAmmo", decreaseAmmo, false, Enum.UserInputType.MouseButton1)

Hierarchy for the UIs:
image

And this is the video as a result:

I have done some testing and this is what I found out:

I tried to restart Studio and the bug still occurred
I tried to open the place on another device in studio and the bug still occurred
I tried to publish it and play on the roblox website and the bug still occurred

But I am still pretty sure this is a studio bug