function Ability:cooldown(cooldownTime, _restingTimeAbility) game.StarterGui.ScreenGui.TextLabel.BackgroundTransparency = 1 game.StarterGui.ScreenGui.TextLabel.BorderSizePixel = 3 game.StarterGui.ScreenGui.TextLabel.BorderColor3 = 232, 152, 22 for i = 1, cooldownTime do print (_restingTimeAbility) game.StarterGui.ScreenGui.TextLabel.Text = _restingTimeAbility _restingTimeAbility = _restingTimeAbility - 1 wait(1) end end
So my code only changes the first thing it sees in my code. The code itself should work fine. Because it prints in output that I want. But it only changes one thing in the gui.
The script is a Script in my Workspace. //game.workspace.Script (Not a localscript) The Gui TextLabel is in startergui. //game.StarterGui.ScreenGui.TextLabel
Greetings from a programmer that's new in LUA :) and thanks in advance.
From what I can tell, your problem should have an easy solution!
Make sure when you're trying to change properties in GUIs that you are calling the GUI in the player, and not in StarterGui, StarterGui is where GUIs are replicated to PlayerGui.
So you need to change the property inside PlayerGui, not StarterGui
function Ability:cooldown(cooldownTime, _restingTimeAbility) Player.PlayerGui.ScreenGui.TextLabel.BackgroundTransparency = 1 Player.PlayerGui.ScreenGui.TextLabel.BorderSizePixel = 3 Player.PlayerGui.ScreenGui.TextLabel.BorderColor3 = 232, 152, 22 for i = 1, cooldownTime do print (_restingTimeAbility) game.StarterGui.ScreenGui.TextLabel.Text = _restingTimeAbility _restingTimeAbility = _restingTimeAbility - 1 wait(1) end end
I used Player.PlayerGui as an example but you're going to need to define Player obviously.
Also, most of the properties in a Gui can only be changed from a LocalGui. Therefore I suggest using RemoteEvents to ask a LocalScript to change the Gui properties for you.
More on remotes here.