I am making offices for my game for the HR ranks, i have a table of whitelisted people which can be added to by a gui, my problem is this bit of code here:
for i,v in pairs(owner) do script.Parent.Parent.unauthkill.Touched:Connect(function(tch) if tch.Parent:FindFirstChild("Humanoid") then if tch.Parent.Name ~= v then tch.Parent:FindFirstChild("Humanoid").Health = 0 end end end)
this is supposed to kill anyone who isn't in the table "owners" (whitelisted) but insted, if there are two people in the table, let's say "PersonA" and "PersonB", PersonA wil be fine but the script will kill "PersonB" because in the eyes of the script, PersonA is not PersonB
Does anyone know how to make it check all users of a table first and then take action? If you do I would be great full if you could help :)
If you'd have a table with all the names put in using the Dictionary style of tables, it's extremely easy.
local AllowedIn = { ["Username"] = true, ["3923232"] = true -- userid or username } --Touch function Object.Touched:Connect(function(Hit) --Get player from character if a character touched the part local Player = game.Players:GetPlayerFromCharacter(Hit.Parent) --check if their name or userid is in the dictionary if Player and not (AllowedIn[Player.UserId] or AllowedIn[Player.Username]) then Player.Character:BreakJoints() end end)