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

How to make a specific name have a GUI shown?

Asked by
G2FU 9
4 years ago

Hello, I am trying to make a local script that (let's say that "Player1" and "Player2" joins) gives Player1 and Player2 specific GUI and not Player3. I found something like this on the internet, but it was a script to only give the gui to you. I tried to modify it, but it turns out that it will give everyone the Gui in game, so the script that I tried to make changes to doesn't work. Here is the local script:

while true do
    if game.Players.LocalPlayer.Name == "Player1" or "Player2" then
    wait()
    else
    script.Parent:Destroy()
    end
end

Doing this makes all players get the gui, and I don't want that to happen. How would I make it so that only (lets say) Player1 and Player2 get the gui? Sorry if it is really simple because I don't really know how to write scripts.

0
Where is the LocalScript placed? 123nabilben123 499 — 4y
0
Its under >StarterGui > ScreenGui > LocalScript G2FU 9 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Hello. First of all you don't need to run a while true do loop to detect the name. This can be done by running the script a single time. Second, instead of deleting the script, you can have it run once and then stop. This setup requires you to put your ScreenGui in ReplicatedStorage

local Player = game.Players.LocalPlayer--Here, we define the player.
if Player.Name == "Player1" or "Player2" then--If player is equal to x or y then
    local Gui = game.ReplicatedStorage.ScreenGui:Clone()--Defines what ScreenGui to copy
    Gui.Parent = Player.PlayerGui--Sets copied ScreenGui into PlayerGui

end

If you found this helpful, please accept the answer.

0
Also, put this LocalScript inside StarterCharacterScripts. jensar141215 157 — 4y
0
Thank you, this fixed the problem! G2FU 9 — 4y
Ad

Answer this question