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

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

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.

8 comments

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.

0

so if i check for the player id?

0

You'd do it as if id == "Name1" or id == "Name2" then .

0

should i use script. parents to get the player name since the script is inside of the player?

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)

0

ok

0

should i use .Name or :GetFullName() or are they both the same thing

0

I recommend .Name, since (if memory serves) GetFullName will return something like game.Players.Player_Name.

1 answer

✓ Accepted answer

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

2 comments

0

On your line 11, you stil didn't fix a mistake.

0

Nice.

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