Hey all,
I’m having an issue where the Gui on my tool is not updating. If someone could tell me why it isn’t working that’d be greatly appreciated. I tried looking up multiple resources but none of them were helpful.
As you can see in the Output bar, the print comes through but the text doesn’t update
Local Script:
local text = script.Parent:WaitForChild("Handle").SurfaceGui.Frame.currentLevel.Text
local mag = (script.Parent.Handle.Position - game.Workspace.enemyPart.Position).magnitude
local static1 = script.Parent.Handle.SurfaceGui.Frame.static1
local static2 = script.Parent.Handle.SurfaceGui.Frame.static2
static1.ImageTransparency = 1
wait(.025)
static1.ImageTransparency = 0.75
if mag > 75 then
text = "No trace of anomaly detected."
print("No trace of anomaly detected.")
elseif mag < 75 and mag >= 55 then
text = "Small trace of anomaly detected."
print("Small trace of anomaly detected.")
elseif mag < 55 and mag >= 35 then
text = "Nominal trace of anomaly detected."
print("Nominal trace of anomaly detected.")
elseif mag < 35 and mag >= 15 then
text = "Huge trace of anomaly detected!"
print("Huge amount detected")
elseif mag < 15 then
text = "#@*FgJH&^#"
print("#@*FgJH&^#")
end
end
i believe you may to change the variable text from
script.Parent:WaitForChild(“Handle”).SurfaceGui.Frame.currentLevel.Text
to
script.Parent:WaitForChild(“Handle”).SurfaceGui.Frame.currentLevel
and manipulate text by
if mag > 75 then
text.Text = "No trace of anomaly detected."
print("No trace of anomaly detected.")
end
if this works you can probably change local text to be local currentLevel so you can do currentLevel.Text to be more readable for you. I hope this helps
It’s because when you first assigned the text variable, you assigned it to your TextLabels string name and not the object itself.
Essentially you assigned this variable to the string Text, and each time you reassigned it based in the state of mag, you are simply changing a string to another string, but not reassigning the TextLabel objects Text property.
Let’s say you have a TextLabel in a frame. TextLabel is an object and TextLabel.Text will return the string text of the object.
So if you have a variable text set equal to TextLabel.Text it will equal the string value returned from Text.
local TextLabel = Frame.TextLabel – object TextLabel
local name = TextLabel.Text --string text property
TextLabel.Text == “foo”
name == “bar”
print(TextLabel.Text, name) – would print “foo”, “bar”