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

StarterGui Not Being Disenabled?

So I have made a script that runs whenever a player joins my game a Screen Gui pops up on the screen with the players name(Label Text) and thumbnail picture (Image Label). The script is located in Workspace and for some reason the script doesn't work. The problem is that I have scripted the Text Label and the Image Label to be turned off after a couple of seconds and it doesn't turn off via the value "Enabled". Is "Enabled" a true or false value? I have exhausted all theories and theorems, I am not sure what to do. Any feedback is appreciated thank you. Here's the script:

local Players = game:GetService("Players")
-- ^ Gets Players

local Textlabel = game.StarterGui.PlayerJoin.TextLabel
--^ Text label location

local Picture = game.StarterGui.PlayerJoin.ImageLabel
--^ Image label location

local Screengui = game.StarterGui.PlayerJoin
--^ Screen gui location and gui that makes the image label and text label not visible or not enabled

Players.PlayerAdded:Connect(function(player)
--^ Function runs whenever a player joins the game or server
	Screengui.Enabled = true
        --^ Makes the Screengui visible
	Textlabel.Text = player.Name.. " joined the game!"
	--^ Text label that prints player name joined the game
	wait(5)
	--^ waits 5 seconds 
	print("I have waited 5 seconds!")
	--^ Confirms that 5 seconds has passed
	Screengui.Enabled = false
	--^ Is supposed to make the screen Gui not enabled thus making the image label and 
        --text label not visible
end)
-- Code below displays message that player has left the game
Players.PlayerRemoving:Connect(function(player)
	Textlabel.Visible = true
	print(player.Name.. " has left the game!")
	
end)

Heres Pictures of Roblox Explorer: (https://ibb.co/znWGSvj)

(http://ibb.co/KbRNNRV)

3 answers

The weird thing is that when I used my regular script, the one in the post it works to enable the screen gui together with the label text and image label. So it shows up visible. But when the game is played it will become enabled and not enabled only if I go to the explorer (while my character loaded) and manually with my mouse then go to Explorer>Players>MyName(Flognaw3210)> PlayerGui>PlayerJoin(ScreenGui) go to properties from screengui and uncheck and check it enabled and it turns on and off just how I would like it too. But how would i script it so the screengui is toggled on and off from Explorer>Players>MyName(Flognaw3210)> PlayerGui>PlayerJoin(ScreenGui)?. Because it looks like that is the only way for it to be toggled on and off, but i am not that educated in scripting I am just beginning to start learning, so I don't really know much commands.

So you can make the Gui.Visible propriety turned off, but I don't think that's the problem.

The problem is that: the GUI goes to the player after the game loads, not to the ScreenGui Service.

Ok, but there are more problems. You're trying to run a script server -side (a normal script does that) in the PlayerGui, a local service of all players.

So here's what you can do to solve that problem: you can fire an RemoteEvent, with the :FireAllClients() function to display that the player left on their GUI's. See the example:

Insert an remote event on ReplicatedStorasge, exaple: newoldplayer

-- Normal script --
local hibye = game.ReplicatedStorage.newoldplayer

game.Players.PlayerAdded:Connect(function(player)
       hibye:FireAllClients(true) -- Im using true as to say if the player joined and false if he left.
end)

game.Players.PlayerRemoving:Connect(function(player)
	hibye:FireAllClients(false) -- Player left.
end)

Now onto the local script, which you could parent it to the GUI:

-- Local Script --
local hibye = game.ReplicatedStorage.newoldplayer
local gui = script.Parent
local TextLabel = gui.TextLabel
local ImageLabel = gui.ImageLabel
hibye.OnClientEvent:Connect(function(player, joined)
      if joined then
	  gui.Visible = true
        TextLabel.Text = tostring(player.. " joined the game!")
        wait(5)
	gui.Visible = false
	else
     		gui.Visible = true
        TextLabel.Text = tostring(player.. " left the game!")
        wait(5)
	gui.Visible = false
	end
end)

Hope it works!

5 comments

1

Hope you enjoyed I'm too slow for coding lol

1

You'd do (player, true)

1

NOT just (true), true is a key word, it's passed in a function or a parameter depending on the code, you would pass a true to turn something on,

1

Hi thank you for replying. I have tried this and it sadly does not work still. I made have the remote event and named it in replicated storage. I have made one regular script and placed it in the remote event newoldplayer. I have made the local script and placed it in my screengui so it is the parent of the local script. Sadly it still does not work I dont know why roblox has to be so complicated.

1

Its ok I'm beginner lol

Well, first off, i suggest you use Player.PlayerGui.ScreenGui.TextLabel as startergui is not going to be there whenever the player joins well it will but it will transfer over to the PlayersGUI to make it actually APPEAR, I suggest you try doing something with

if value.Enabled == true then
-- Code Here
end

OR!

if ...Value == ...Value then
--... Is the placement of your value such as 

if script.Parent.Parent.Parent.Coins.Value == 100 then

-- This will check if the coins are that certain thing then do stuff with it.
end

Hope this helped!

3 comments

1

Yea you just pasted a code that's not how script learning works

1

Hi thanks for replying, like I said in my post I have exhausted all theories and theorems and have tried what you already said before posting my questions. It sadly didn't work.

0

" 1 Yea you just pasted a code that's not how script learning works"And you're talking sadly, I cannot say anything but just don't be annoying or rude. I was simply helping.

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