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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

Ad

Answer this question