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:
01 | local Players = game:GetService( "Players" ) |
02 | -- ^ Gets Players |
03 |
04 | local Textlabel = game.StarterGui.PlayerJoin.TextLabel |
05 | --^ Text label location |
06 |
07 | local Picture = game.StarterGui.PlayerJoin.ImageLabel |
08 | --^ Image label location |
09 |
10 | local Screengui = game.StarterGui.PlayerJoin |
11 | --^ Screen gui location and gui that makes the image label and text label not visible or not enabled |
12 |
13 | Players.PlayerAdded:Connect( function (player) |
14 | --^ Function runs whenever a player joins the game or server |
15 | Screengui.Enabled = true |
Heres Pictures of Roblox Explorer: (https://ibb.co/znWGSvj)
(http://ibb.co/KbRNNRV)
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
01 | -- Normal script -- |
02 | local hibye = game.ReplicatedStorage.newoldplayer |
03 |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | hibye:FireAllClients( true ) -- Im using true as to say if the player joined and false if he left. |
06 | end ) |
07 |
08 | game.Players.PlayerRemoving:Connect( function (player) |
09 | hibye:FireAllClients( false ) -- Player left. |
10 | end ) |
Now onto the local script, which you could parent it to the GUI:
01 | -- Local Script -- |
02 | local hibye = game.ReplicatedStorage.newoldplayer |
03 | local gui = script.Parent |
04 | local TextLabel = gui.TextLabel |
05 | local ImageLabel = gui.ImageLabel |
06 | hibye.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 |
18 | end ) |
Hope it works!
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
1 | if value.Enabled = = true then |
2 | -- Code Here |
3 | end |
OR!
1 | if ...Value = = ...Value then |
2 | --... Is the placement of your value such as |
3 |
4 | if 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. |
7 | end |
Hope this helped!