Last active
November 29, 2020 04:08
-
-
Save howmanysmall/15da41a8839486efc389f18f380846ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Players: Players = game:GetService("Players") | |
local CollectionService: CollectionService = game:GetService("CollectionService") | |
local RunService: RunService = game:GetService("RunService") | |
local Door: Part = script.Parent | |
local POSSIBLE_CODES: {[string]: boolean} = { | |
["bruce wayne"] = true; | |
["batman"] = true; | |
} | |
local function Wait(Seconds: number): number | |
Seconds = math.max(Seconds or 0.03, 0) | |
local TimeRemaining: number = Seconds | |
while TimeRemaining > 0 do | |
TimeRemaining -= RunService.Heartbeat:Wait() | |
end | |
return Seconds - TimeRemaining | |
end | |
local function Chatted(Message: string): nil | |
if POSSIBLE_CODES[string.lower(Message)] then | |
Door.Transparency = 0.5 | |
Door.CanCollide = false | |
Wait(1) | |
Door.CanCollide = true | |
Door.Transparency = 0 | |
end | |
end | |
local function PlayerAdded(Player: Player): nil | |
if not CollectionService:HasTag(Player, "IsConnected") then | |
CollectionService:AddTag(Player, "IsConnected") | |
Player.Chatted:Connect(Chatted) | |
end | |
end | |
Players.PlayerAdded:Connect(PlayerAdded) | |
for _, Player: Player in ipairs(Players:GetPlayers()) do | |
PlayerAdded(Player) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment