Help with Module script

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

Put some print requests in your first script, and in the module script, so when things run you can see where it stops running so we can help to determine where the hang up is at since you’re not getting an error message

Ok thanks, I added those in and still no errors occured. I realized line 10 of the script wasn’t written correct bcause I transformed the script into a module script. Then when I fixed it I got a ton of new errors, most of them with the location of the part being wrong. I was able to fix it and it works fine now

1 Like