Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

TextLabel change question via script?

Asked by 6 years ago
Edited 6 years ago
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.

0
So explain us a bit what do you need exactly ? LordTechet 53 — 6y
1
You're supposed to change the GUIs in PlayerGui, not StarterGui. UgOsMiLy 1074 — 6y

1 answer

Log in to vote
0
Answered by
Troidit 253 Moderation Voter
6 years ago

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.

0
Thanky you very much for your quick and good answer! lordjarno6 4 — 6y
0
How do I get in the PlayerGui to add a GUI? I'm looking for it the whole time but can't find it on internet or in roblox studio. lordjarno6 4 — 6y
0
Anything in the startergui is automatically copied to the playergui once the player joins. If you want to add more guis, just change the parent of the GUI you want to the PlayerGui Troidit 253 — 6y
Ad

Answer this question