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

Working with leaderstats and GUI's, TextLabel won't appear, what should I do?

Asked by 5 years ago
Edited 5 years ago
local function AddToNoobs()
    if script.Parent.Parent.Parent.Parent.Parent.Noob.Noobs.Value <= 25 then
        game.StarterGui.ScreenGui.TextLabel.Visible = true
        wait(5)
        game.StarterGui.ScreenGui.TextLabel.Visible = false
    else
        script.Parent.Parent.Parent.Parent.Parent.Noob.Noobs.Value = script.Parent.Parent.Parent.Parent.Parent.Noob.Noobs.Value + 1

    end
end

script.Parent.MouseButton1Click:Connect(AddToNoobs)

As I said, no errors appear, the main part that I believe is not working is the statement to make the TextLabel visible, as everything else in the script works. My script can't be local due to the fact that I need to edit the leaderstats.

0
You cant change a player's gui with the StarterGui, assuming this is a local script, use the hierarchy like you did for the noobs value to get the textlabel instead SerpentineKing 3885 — 5y
0
First i'd go ahead and make a variable for the value instead of typing that long thing every time ForeverBrown 356 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

startergui is used by the server to replicate a gui for every player that joins. When working with gui, reference game.Players.LocalPlayer.PlayerGui

for example:

   game.StarterGui.ScreenGui.TextLabel.Visible = true

would be

   game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = true

Remember to use a localscript while working with client replicated stuff such as guis. If you need to use something serversided, use a remote event. for remotes go here:

https://developer.roblox.com/articles/Remote-Functions-and-Events

0
My script can't be local because I need to edit the value of the leaderstats, and are you saying that the gui would be visible to everyone if I use a normal script? ScottVulpes 105 — 5y
0
since guis are client sided u have to use a localscript.to communicate with the server so the server can do something use a remote EmbeddedHorror 299 — 5y
Ad

Answer this question