Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a gui pop up for a certain player when they join the game?

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?

1 comment

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

0

Make sure you have a remote event because the server will tell the local script to fire an event like a gui.

0

These are both local scripts in the Gui itself @JesseSong

0

Ik but wheres the remote event?

0

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

0

Just a note for @Seashell_Luna if you're doing this then the Gui or script shouldn't be in StarterGui

0

^ Yeah.

0

You must need remote event and remote function. Therefore this script is incorrect

0

@JesseSong It works for me in studio. I used a ServerScript inside ServerScriptService.

0

Ik but what if someone exploited or changed their name this is where remote events are useful

0

Just use UserId. Exploiters can't change their UserId.

This discussion is preserved as it was. New answers, comments, and votes are closed.