Need help with if player.Name ==

trying to make a UI where only certain people can see this specific text.

here is the script.
(no errors show)

if player.Name == "qtaian" then

script.Parent.Text = "Welcome, qtIan, you are deemed; owner."

else

script.Parent.Text = "Welcome you are deemed; guest."

wait(5)

script.Parent.TextTransparency = 1

end
1 Like

Wheres the declared player at?

You should deactivate the visibility of the text instead of the transparency

no, i like it my way. it looks better.

you mean, the player for this text to appear for is me “qtaian”

If your name on roblox has a capital I, this is why your script does not work. The selection checks for “qtaian”, but your name is “qtaIan”.

Use string.lower(player.name) to check without being case sensitive. The better alternative to both is to use UserIds instead.

I believe the code is a localscript

So I made a better one:

local LocalPlayer = game.Players.LocalPlayer
local Allowed = {12345678; 12300000;} --UserID instead so you are not gonna do some hardwork to spell their names.
local function allowedPeople(thisPlayer)
    for _, playerID in pairs(Allowed) do
        if playerID == thisPlayer.UserId then
            return true
        end
    end
end

if allowedPeople(LocalPlayer) == true then
    script.Parent.Text = "Welcome, qtIan, you are deemed; owner."
else
    script.Parent.Text = "Welcome you are deemed; guest."
    wait(5)
    script.Parent.TextTransparency = 1
end
5 Likes

thanks, that solved it!! :grinning_face_with_smiling_eyes:

wait, i have one more question, if i would like to state their name in the text what do i do?

script.Parent.Text = "Welcome,"..Player.Name." to example"

You’d say:

script.Parent.Text = "Welcome, " .. LocalPlayer.Name .. " to example"
4 Likes