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

How to check if the player's name is in a table ?

Hello ,

im making a ittle mini game and now im trying to check if a player has the same name in a table

I tried this :

local P = game.Players.LocalPlayer

local Vip = {"213445F","Somerandomdude","RRG"}

if P.Name == ???? then .....

I hope you understand thanks !

1 answer

✓ Accepted answer
local function IsInTable(t, val)
	for i,v in pairs(t) do
		if v == val then
			return true
		end
	end
	return false
end

local P = game.Players.LocalPlayer

local Vip = {"213445F","Somerandomdude","RRG"}

if IsInTable(Vip, P.Name) then
	--stuff
end

1 comment

0

Thanks for the quick reply !

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