Custom AdminGui Help

So Im attempting to make an AdminGui. Instead of actually giving errors in the output I’d want it to instead say an error message in the Admingui.

image

If I type a random name that doesn’t exist it should say “Object Unexisted” then after Two seconds it goes back to “Confirm” however it if the Object doesn’t exist it gives an error.

I tried swapping the two statements around but that just did the opposite of what i wanted it to do.

Hi. First of all, you are unnecessarily assigning the same value to two variables, name and TextBox; you can get rid of one of them.

As you can see in the output, the error is in line 3. Your script is trying to index “QWEQWE” in the workspace, and it errors because it can’t find the object. Use Roblox built-in function :FindFirstChild(), which will return nil (but not error) if the object doesn’t exist (as you did a few lines underneath):

local PlayerName = workspace:FindFirstChild(TextBox)

Then, check if playerName is nil or not (you can do this along with your check):

if PlayerName and game.Players:FindFirstChild(TextBox) then
-- the code nested here should work properly now
end

I’d recommend using less confusing names for the variables (e.g. “character” instead of “PlayerName”).

2 Likes

Thanks for the advice. I was confused why mine didn’t work.

1 Like