I am attempting to make a power level system for my ship, and I wanted a GUI to say the exact power level. I started off with something very basic, or at least I thought it was basic. The text of the GUI does not set in the function. However, if I move the setText outside of the function, the GUI updates. When the function runs, the power value does increase, but the GUI text is not changed. Any ideas?
power = script.Parent.Power
gui = game.StarterGui.ScreenGui.TextBox
function powerIncrease()
power.Value = power.Value + 1
gui.Text = "Power level: "..power.Value
end
script.Parent.Add.ClickDetector.MouseClick:connect(powerIncrease)
vs this:
power = script.Parent.Power
gui = game.StarterGui.ScreenGui.TextBox
function powerIncrease()
power.Value = power.Value + 1
end
gui.Text = "Power level: "..power.Value
script.Parent.Add.ClickDetector.MouseClick:connect(powerIncrease)

2 comments
The thing is that the text will only update when you call the powerIncrease function, so when you first start up, since you haven't pressed the ClickDetector, it won't update the text.
Hi, thank you for your reply. I forgot to specify. I am running the function. The power level increases every time. But the text of the GUI still doesn't change. The function completes, but skips over the GUI text.