I want this script to be the same but make it so "pacjad" and "Therealfluff123" can enter and not only "pacjad"
This is the script:
local restrictedArea = script.Parent -- The part the player needs to touch to enter
local allowedUsername = "pacjad" -- The username that is allowed to enter the area
local regionPart = restrictedArea -- This is the part you're using to define the restricted area
-- This function checks if the player is allowed
restrictedArea.Touched:Connect(function(hit)
-- Check if the object that touched the part is a player's character
local character = hit.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(character)
-- If the object that touched the part is a player
if player then
-- Check if the player's username matches the allowed one
if player.Name == allowedUsername then
-- Player is allowed to enter, you can add actions here if needed
print(player.Name .. " is allowed to enter the restricted area!")
else
-- Player is not allowed to enter, stop them from entering
print(player.Name .. " is not allowed to enter.")
-- Make the player unable to pass through by disabling their ability to move through the area
-- You can use a temporary invisible part (or simply use a large barrier) that blocks the player
-- You don't need to push or teleport them; they'll just be blocked.
-- To make the player stop entering the area, you can make the restricted area a barrier (visible or invisible)
restrictedArea.CanCollide = true -- Ensure the part is collidable
end
end
end)