Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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?

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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)
0
Make sure you have a remote event because the server will tell the local script to fire an event like a gui. JesseSong 3916 — 4y
0
These are both local scripts in the Gui itself @JesseSong kingblaze_1000 359 — 4y
0
Ik but wheres the remote event? JesseSong 3916 — 4y
0
How do I fire the remote event? Doesn't that have to be in a seperate place Seashell_Luna 3 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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
0
Just a note for @Seashell_Luna if you're doing this then the Gui or script shouldn't be in StarterGui kingblaze_1000 359 — 4y
0
^ Yeah. youtubemasterWOW 2741 — 4y
0
You must need remote event and remote function. Therefore this script is incorrect JesseSong 3916 — 4y
0
@JesseSong It works for me in studio. I used a ServerScript inside ServerScriptService. youtubemasterWOW 2741 — 4y
View all comments (2 more)
0
Ik but what if someone exploited or changed their name this is where remote events are useful JesseSong 3916 — 4y
0
Just use UserId. Exploiters can't change their UserId. youtubemasterWOW 2741 — 4y

Answer this question