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)
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!
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!