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

StarterGui Not Being Disenabled?

Asked by 4 years ago

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:

01local Players = game:GetService("Players")
02-- ^ Gets Players
03 
04local Textlabel = game.StarterGui.PlayerJoin.TextLabel
05--^ Text label location
06 
07local Picture = game.StarterGui.PlayerJoin.ImageLabel
08--^ Image label location
09 
10local Screengui = game.StarterGui.PlayerJoin
11--^ Screen gui location and gui that makes the image label and text label not visible or not enabled
12 
13Players.PlayerAdded:Connect(function(player)
14--^ Function runs whenever a player joins the game or server
15    Screengui.Enabled = true
View all 32 lines...

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

(http://ibb.co/KbRNNRV)

3 answers

Log in to vote
1
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

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

01-- Normal script --
02local hibye = game.ReplicatedStorage.newoldplayer
03 
04game.Players.PlayerAdded:Connect(function(player)
05       hibye:FireAllClients(true) -- Im using true as to say if the player joined and false if he left.
06end)
07 
08game.Players.PlayerRemoving:Connect(function(player)
09    hibye:FireAllClients(false) -- Player left.
10end)

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

01-- Local Script --
02local hibye = game.ReplicatedStorage.newoldplayer
03local gui = script.Parent
04local TextLabel = gui.TextLabel
05local ImageLabel = gui.ImageLabel
06hibye.OnClientEvent:Connect(function(player, joined)
07      if joined then
08      gui.Visible = true
09        TextLabel.Text = tostring(player.. " joined the game!")
10        wait(5)
11    gui.Visible = false
12    else
13            gui.Visible = true
14        TextLabel.Text = tostring(player.. " left the game!")
15        wait(5)
16    gui.Visible = false
17    end
18end)

Hope it works!

1
Hope you enjoyed I'm too slow for coding lol bruno13bruno13 78 — 4y
1
You'd do (player, true) Nicholas1088 169 — 4y
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, Nicholas1088 169 — 4y
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. Flognaw3210 25 — 4y
1
Its ok I'm beginner lol bruno13bruno13 78 — 4y
Log in to vote
0
Answered by 4 years ago

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

1if value.Enabled == true then
2-- Code Here
3end

OR!

1if ...Value == ...Value then
2--... Is the placement of your value such as
3 
4if script.Parent.Parent.Parent.Coins.Value == 100 then
5 
6-- This will check if the coins are that certain thing then do stuff with it.
7end

Hope this helped!

1
Yea you just pasted a code that's not how script learning works bruno13bruno13 78 — 4y
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. Flognaw3210 25 — 4y
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. Nicholas1088 169 — 4y

Answer this question