local Players = game:GetService("Players")
local door = script.Parent
local whitelistTable = {1455078586}
local function playerExplode(hit)
local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
local player = Players:GetPlayerFromCharacter(hit.Parent)
for i = 1, #whitelistTable do
if whitelistTable[i] ~= player.UserId then
if Humanoid then
local Explosion = Instance.new("Explosion")
Explosion.Parent = script.Parent
Explosion.Position = script.Parent.Position
Humanoid.Health = 0
end
end
end
end
local function checkPermission(hit, doorPart)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local player = Players:GetPlayerFromCharacter(char)
for i = 1, #whitelistTable do
if whitelistTable[i] == player.UserId then
door.Color = Color3.fromRGB(0,255,0)
door.CanCollide = false
wait(3)
door.Color = Color3.fromRGB(99,95,98)
door.CanCollide = true
else
door.Color = Color3.fromRGB(255,0,0)
wait(3)
door.Color = Color3.fromRGB(99,95,98)
playerExplode(hit)
end
end
end
end
door.Touched:Connect(checkPermission)```
I have this script here but the problem is if i add more IDs to the whitelistTable it will execute the denial access part instead of only doing accept
any idea on how to fix that? even if my ID is not at the start it first goes through the for loop then executes the correct event for the player
#permissionLoop
13 messages · Page 1 of 1 (latest)
@mighty lark use table.find
thanks ill try that
but will it stop once found bc i will need it to first finish then execute the correct event
i kinda need it to stop after the ID is found
table.find either returns an index or nil
it's not a loop
oh
if table.find(whitelistTable, player.UserId) then
-- is in the list
else
--is not in the list
end
that can replace your entire for loop