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

Why doesn't the player's gui get deleted?

So I am trying to make a script where if the player who joins' name is a certain name, it makes a StarterGui in the player's PlayerGui delete. Here's what I have:

game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name ~= "I_vNextLevel" then
		plr.PlayerGui.Epic:Destroy()
	end
end)

(Epic is the name of the StarterGui)

1 answer

✓ Accepted answer

What you would wanna do is use both userids and some more... Finding things. Heres an example that would work for you (Place either in the GUI or in PlayerScripts as a local script)

local Plr = game.Players.LocalPlayer
local PlayerGui = Plr:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild("Epic")

if Plr.UserId ~= 29572815 then --Replace the Id with your Id
	Gui.ResetOnSpawn = false
	Gui.Enabled = false
end

It's best not to destroy as it will just come back if they die unless by default it doesnt have reset on spawn. Just put protection into the scripts inside it so exploiters don't make use of it.

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