I'm quite new to scripting and I'm having some difficulties. I'm trying to make a GUI pop up for whenever a certain player joins the game. Kind of like a message just for them. Just for the one player. Nobody else. I also need a button that will close the GUI when they're done reading. Can anybody give me some pointers on how to do this?
How can I make a gui pop up for a certain player when they join the game?
2 answers
game.Players.PlayerAdded:Connect(function(plr)
if plr.Name == "CertainName" then
local gui = plr.PlayerGui.CertainGui.Frame
gui.Visible = true --Or you could tween the gui here if you wanted to
end
end)
This is a local script btw
--This script is for the button, place the button in the frame and this script inside it as a local script
local button = script.Parent
local gui = script.Parent.Parent
button.MouseButton1Click:Connect(function()
gui.Visible = false --//Tweening here if wanted
end)
5 comments
Make sure you have a remote event because the server will tell the local script to fire an event like a gui.
These are both local scripts in the Gui itself @JesseSong
Ik but wheres the remote event?
How do I fire the remote event? Doesn't that have to be in a seperate place
You will need to use the PlayerAdded event just as the following.
Make sure you make it a ServerScript (Normal).
local Players = game:GetService("Players") -- Gets the service Players.
local specificPlayer = "" -- Put the username inside the quotes.
local function onPlayerAdded(player)
if player.Name == specificPlayer then -- Checking if the player's name is equal to the specificPlayer variable
local gui = script:WaitForChild("ScreenGui"):Clone() -- Clones the gui (Assuming you'd put the gui inside the script)
gui.Parent = player:WaitForChild("PlayerGui") -- Sets the gui's parent to the player's PlayerGui
end
end
Players.PlayerAdded:Connect(onPlayerAdded) -- Connects the event to the function
6 comments
Just a note for @Seashell_Luna if you're doing this then the Gui or script shouldn't be in StarterGui
^ Yeah.
You must need remote event and remote function. Therefore this script is incorrect
@JesseSong It works for me in studio. I used a ServerScript inside ServerScriptService.
Ik but what if someone exploited or changed their name this is where remote events are useful
Just use UserId. Exploiters can't change their UserId.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Your question is similar to this https://scriptinghelpers.org/questions/70022/how-to-make-gui-popup-for-only-one-player-not-everyone-on-the-server