while true do
if script.Parent.Parent.Destination.Value == 0 then
script.Parent.SurfaceGui.TextLabel.Text = "Not In Service"
end
if script.Parent.Parent.Destination.Value == 1 then
script.Parent.SurfaceGui.TextLabel.Text = "Event Area"
end
if script.Parent.Parent.Destination.Value == 2 then
script.Parent.SurfaceGui.TextLabel.Text = "Central"
end
if script.Parent.Parent.Destination.Value == 3 then
script.Parent.SurfaceGui.TextLabel.Text = "Event Area"
end
if script.Parent.Parent.Destination.Value == 4 then
script.Parent.SurfaceGui.TextLabel.Text = "Airport Loop"
end
if script.Parent.Parent.Destination.Value == 5 then
script.Parent.SurfaceGui.TextLabel.Text = "City Loop"
end
end
The Variable is changing, but the Text won’t change based on what the variable is.\
EDIT: The Problem Is Something To Do With It Not Updating! (While true do)
Have you considered using a .Changed event instead? You can read about them here. Need a bit more information to properly diagnose the problem however. Is this a LocalScript or a ServerScript? Where is it located?
You continue asking an if condition wondering if the value changes, fact is, in the script you provided, the value never changes. Unless, this is not the whole script
This is mostly because you aren’t putting a wait or a task.wait so the code in that loop runs an unlimited amount of times in a single second, therefore exhausting the script. I would suggest doing this
while true do
task.wait()
--stuff
end
instead of
while true do
--stuff
end
Also, I’ve noticed the painful amount of if statements in that loop, I suggest you put an array or a dictionary whose keys are numbers and the values are the strings you want to change the TextLabel’s text to, and I wouldn’t recommend an infinite loop for this given that you could use Instance.Changed or Instance:GetPropertySignalChanged() without bringing up any issue regarding performance.
local dictionary = {
[0] = "Not in service",
[1] = "Event area",
[2] = "Central"
[3] = "Event area",
[4] = "Airport loop",
[5] = "City loop"
}
local destination = script.Parent.Parent.Destination
destination:GetPropertySignalChanged("Value"):Connect(function()
if dictionary[destination.Value] then --Checking if it exists
script.Parent.SurfaceGui.TextLabel.Text = dictionary[destination.Value]
end
end