So this is my code (it is located in ServerScriptService as a regular script):
local players = game:GetService("Players")
local friendDoor = game.Workspace.friendDoor
local users = {
-- this is where i put the id, but I don't want to reveal hers
}
local isAllowed = function(player, tab)
for i, v in pairs(tab) do
if players.LocalPlayer.UserId == v then return true end
end
return false
end
friendDoor.Touched:Connect(function(player)
if isAllowed(player, users) then
friendDoor.CanCollide = false
wait(1)
friendDoor.CanCollide = true
end
end)
When I touch the door/barrier, it gives me this error: 15:47:19.625 - ServerScriptService.OnlyFriendScript:10: attempt to index nil with 'UserId'
Which might mean that I can't get the Id with LocalPlayer?
Just to make sure everyone understands, the objective of this script is to only let my friend through the barrier and no other player on roblox. (Which means that even if I touch the barrier I can't get in, so that is what I am expecting to happen when I test.) Thanks

1 comment
make sure a player is touches the door