Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

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

0

First i'd go ahead and make a variable for the value instead of typing that long thing every time

1 answer

✓ Accepted answer

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

3 comments

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?

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

This discussion is preserved as it was. New answers, comments, and votes are closed.