you will see the value is changed while the text didn’t change
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
using loop(while true do) says error like “exhausted allowed execution time”
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- very simple right?
local TempRecord = workspace:WaitForChild("Temperature")
-- while true do
if script.Parent.Parent.Parent then
script.Parent.Text = "Temp : "..TempRecord.Value.." °C"
end
-- end
You Aren’t yielding per iteration causing the loop to crash the game and break
no other code appears to be running
Therefore the text will only update once, as you aren’t telling it to update, if that if statement is supposed to indicate something, it will only run once, so use a .Changed Event for this instead of a while loop as it is generally more efficient and takes less resources to accomplish.
Another Method for formatting text can be with string.format()
format = string.format
script.Parent.Text = format("Temp : %d °C", newValue) -- updates First outside
TempRecord.Changed:Connect(function(newValue) -- Updates when there is a Change
script.Parent.Text = format("Temp : %d °C", newValue) -- basically formats the string
end)
The issue is that the text is only setting once. Nothing is telling the script to continue reading that temperature value. If you uncommented the while loop, the game will crash because there’s no yield in the loop. What @xGOA7x suggested is the most efficient and practical, I would go with that.