Second, add a local script into StarterPlayerScripts and paste this into it.
Location:
Script:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local RemoteEvent = ReplicatedStorage.RemoteEvent
local Door = workspace.Door --//Reference your door
--//Functions
RemoteEvent.OnClientEvent:Connect(function()
--//Make door invisible
Door.CanCollide = false
Door.Transparency = 1
end)
Lastly, add a server script into ServerScriptService and paste this into it:
Location:
Script:
--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local Code = "MyCode"
local RemoteEvent = ReplicatedStorage.RemoteEvent
--//Functions
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(text)
if text == Code then
RemoteEvent:FireClient(player)
end
end)
end)
It should work now. Change the code variable and door variable to match your situation.
--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local RemoteEvent = ReplicatedStorage.RemoteEvent
--//Tables
local Codes = { --//Reference your codes here
"MyFirstCode",
"MySecondCode",
}
--//Functions
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(text)
if table.find(Codes, text) then
RemoteEvent:FireClient(player, text)
end
end)
end)
And the local script to this:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local RemoteEvent = ReplicatedStorage.RemoteEvent
--//Doors
local Door1 = workspace.Door1 --//Reference your door
local Door2 = workspace.Door2 --//Reference your door
--//Functions
RemoteEvent.OnClientEvent:Connect(function(text)
if text == "MyFirstCode" then
Door1.CanCollide = false
Door1.Transparency = 1
elseif text == "MySecondCode" then
Door2.CanCollide = false
Door2.Transparency = 1
end
end)