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

How to make a specific name have a GUI shown?

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.

2 comments

0

Where is the LocalScript placed?

0

Its under >StarterGui > ScreenGui > LocalScript

1 answer

✓ Accepted answer

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.

2 comments

0

Also, put this LocalScript inside StarterCharacterScripts.

0

Thank you, this fixed the problem!

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