What this script does is look for a player named "JustARegularGuy804" which is me, then make a GUI pop up for 10 seconds, then disappear.
if game.Players.Name == "JustARegularGuy804" then script.Parent.RegularGuy.Visible = true wait(10) script.Parent.RegularGuy.Visible = false end
The GUI seems to just stay there permanently, plus I have 2 of these to see if it's broken, used the SAME script, with different names, but it seems to still not work.
By the way, the TextBox name is "RegularGuy".
In order to have a GUI popup for only a user named JustARegularGuy804 use a script like follows.
game.Players.PlayerAdded:connect(function(plr) --PlayerAdded Event | Fires when a new player joins the server if(plr.Name == "JustARegularGuy804") then --We compare the new players name with your name plr.CharacterAdded:connect(function() --Once this player spawns, show the GUI script.Parent.Visible = true wait(10) script.Parent.Visible = false end) end end)
This script should be under the object you wish to hide.
I should say that nothing in the PlayerGUI is private. If they know how, they can read all the contents.
This will also show up every time they respawn. If you don't want that, add a debounce to check if they've spawned before.
Futher Reading: PlayerAdded Event CharacterAdded Event
You are checking if the service Players's Name property is equal to yours. In order to get your idea working, you would have to keep track of all entrances. Therefore, you would want to use a RBXScriptSignal or event
to run your check.
The PlayerAdded
event will be best in this context... However, it doesn't work as expected in LocalScripts, so you would have to make sure that it's in a regular (server) script.
game.Players.PlayerAdded:connect(function (player) --check end)
then, you could check if the name of the player matches yours.
if player.Name == 'mine' then --clone end
finally, you would want to actually clone the gui from somewhere other than StarterGui
, into the player's or everyone's PlayerGui
. Altogether, your script should look something like this..
local storage = game:GetService('ReplicatedStorage') local guiFile = storage:WaitForChild('RegularGuy') local name = 'mine' game.Players.PlayerAdded:connect(function (player) if player.Name == mine then local gui = guiFile:clone()
-------- If for one player ---------- gui.Parent = player:WaitForChild('PlayerGui') -------- If for all players ---------- --loop through `game.Players` for i, peer in ipairs(game.Players:GetPlayers()) do --parent gui to peer's playerGui gui.Parent = peer:WaitForChild('PlayerGui') end end
end