Hello, for some reason this module script won’t work. Pretty new to module scripts so not sure what’s wrong with it. No error is given.
Basically, I have a ton of doors that can be opened if the player has a keycard.
Script inside door:
local DoorService = game:GetService("ServerScriptService"):WaitForChild("Server Core"):WaitForChild("Miscellaneous"):WaitForChild("DoorService")
local DS = require(DoorService)
local Door = script.Parent
script.Parent:WaitForChild("MainDoor"):WaitForChild("BlindPart").Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player.Character:FindFirstChild("Keycard") or Player.Character:FindFirstChild("Forged Keycard") then
DS.OpenDoor(Player, Door)
end
end
end)
Module Script
local DoorService = {}
local WaitTime = 1
function DoorService.OpenDoor(Player, Door)
local Bool = Door:WaitForChild("Bool")
if Bool.Value == false then
Bool.Value = true
local BlindBart = Door:WaitForChild("BlindPart")
script.Parent:WaitForChild("AccessLight").Color = Color3.fromRGB(0, 255, 0)
for i,v in pairs(Door:WaitForChild("MainDoor"):GetChildren()) do
if v.Name == "Main" then
v.Transparency = 1
elseif v.Name == "Window" then
v.Transparency = 1
end
end
BlindBart.CanCollide = false
wait(WaitTime)
Door:WaitForChild("AccessLight").Color = Color3.fromRGB(255, 0, 0)
for i,v in pairs(Door:WaitForChild("MainDoor"):GetChildren()) do
if v.Name == "Main" then
v.Transparency = 0
elseif v.Name == "Window" then
v.Transparency = .4
end
end
BlindBart.CanCollide = true
Bool.Value = false
end
end
return DoorService