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

why cant checking for :GetFullName() work when making a whitelist script?

Asked by 5 years ago

i am trying to make a script that doesn't let certain people do certain things unless they are on a whitelist. It doesn't work in game and i don't really know what to do, i have tried many things.

local player = game.Players.LocalPlayer
local gui    = player:WaitForChild("PlayerGui").GameIntro.Start
local audio  = player:WaitForChild("PlayerGui").PlayerAudio
gui.Play.MouseButton1Click:connect(function()
    if workspace.Value.Value == true then
    if gui.Parent.CanClick.Value == true then
    local id = player:GetFullName()            -- gets players full username

        if id == "Creeper_Dude158" or "SteamSkele" then -- checks if the players full name is one of these

-- not important for the issue -- 

        end 
        end
    end 
end)

any player can get through, not the only makes listed there. Any help and a solution? I've been searching for a while now.

the script is in a local script in starter player scripts.

0
You need to check `id` each and every time. (Ex, `if id == val or id == val`) Otherwise, it's telling the script `if id is equal to name or string is true then`. TheeDeathCaster 2368 — 5y
0
so if i check for the player id? Creeper_Dude158 11 — 5y
0
You'd do it as `if id == "Name1" or id == "Name2" then `. TheeDeathCaster 2368 — 5y
0
should i use script. parents to get the player name since the script is inside of the player? Creeper_Dude158 11 — 5y
View all comments (4 more)
0
Nope, getting the LocalPlayer is plenty enough. :) Although if you're saying this's a Script, then `LocalPlayer` wont work. :c (LocalPlayer is for LocalScripts) TheeDeathCaster 2368 — 5y
0
ok Creeper_Dude158 11 — 5y
0
should i use .Name or :GetFullName() or are they both the same thing Creeper_Dude158 11 — 5y
0
I recommend `.Name`, since (if memory serves) `GetFullName` will return something like `game.Players.Player_Name`. TheeDeathCaster 2368 — 5y

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

The function GetFullName() returns the full ancestry string of the object you're calling it from.

What you really want is to compare two strings to see if they're similar. If so, continue with the if statement.

Since you defined the local player all you need is the Name property.

local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui").GameIntro.Start
local audio  = player:WaitForChild("PlayerGui").PlayerAudio

gui.MouseButton1Click:Connect(function()
    if workspace.Value.Value == true then
        if gui.Parent.CanClick.Value == true then
            local id = player.Name -- You're only looking for the name

            if id == "Creeper_Dude158" or id == "SteamSkele" then       
                print(id) -- Printing out the id for testing

end 
        end
    end 
end)

Edit: did booboo, and...

Alternatively you can use a table of strings in which you can loop through to also compare if the name checks out. Usually the most common method for things like this.

local whitelist = {"Jarvis", "Craig", "Tony", "xPolarium"}
local id = "xPolarium"

for _, tag in pairs(whitelist) do
    if tag == id then
        print("Hello there...")
    end
end
0
On your line 11, you stil didn't fix a mistake. User#19524 175 — 5y
0
Nice. xPolarium 1388 — 5y
Ad

Answer this question