I’m trying to find the character so I know what the player is holding, however, my module script isn’t finding the character as it considers it as null.
I have another server script which calls for the module, and that is needed so everyone sees the gate moving.
Module Script:
local GateModule = {}
-- Cl
local clearance = {
"[CCI] CID - III",
"[CCI] CID - IV",
"[CCI] CID - V",
"[CCI] Combative Card",
"[GOI] CID - III",
}
local HackClearance = {
"Hacking Device III",
"Hacking Device IV",
}
local PH = {
"[CCI] CID - 0",
"[CCI] CID - I",
"[CCI] CID - II",
"[GOI] CID - II",
"Hacking Device II",
}
function GateModule.EventInspection(player,Refuse,CountBool,Prompt1,Prompt2,Prompt1e,Prompt2e,Accept,Light1,Light2,Sound,TOpen,Bool,TClose)
local Character = player.Character
for _, item in pairs(Character:GetDescendants()) do
if table.find(clearance, item.Name) then
if Bool.Value == true then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Accept:Play()
Light1.BrickColor = BrickColor.new("Lime green")
Light2.BrickColor = BrickColor.new("Lime green")
Sound:Play()
TClose:Play()
wait(1)
Light1.Color = Color3.fromRGB(95, 94, 94)
Light2.Color = Color3.fromRGB(95, 94, 94)
Bool.Value = false
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
else
if Bool.Value == false then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Accept:Play()
Light1.BrickColor = BrickColor.new("Lime green")
Light2.BrickColor = BrickColor.new("Lime green")
Sound:Play()
TOpen:Play()
wait(1)
Light1.Color = Color3.fromRGB(95, 94, 94)
Light2.Color = Color3.fromRGB(95, 94, 94)
Bool.Value = true
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
end
end
elseif table.find(PH, item.Name) then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Light1.BrickColor = BrickColor.new("Really red")
Light2.BrickColor = BrickColor.new("Really red")
Refuse:Play()
wait(1)
Light1.Color = Color3.fromRGB(95, 94, 94)
Light2.Color = Color3.fromRGB(95, 94, 94)
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
end
end
end
function GateModule.HackInspection(player,Refuse,CountBool,Prompt1,Prompt2,Prompt1e,Prompt2e,Accept,Light1,Light2,Sound,TOpen,Bool,TClose)
local Character = player.Character
if not Character then return end
for _, item in pairs(Character:GetDescendants()) do
if table.find(HackClearance, item.Name) then
if Bool.Value == true then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Accept:Play()
Light1.BrickColor = BrickColor.new("Lime green")
Light2.BrickColor = BrickColor.new("Lime green")
Sound:Play()
TClose:Play()
wait(1)
Light1.Color = Color3.new(0.372549, 0.368627, 0.368627)
Light2.Color = Color3.new(0.372549, 0.368627, 0.368627)
Bool.Value = false
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
else
if Bool.Value == false then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Accept:Play()
Light1.BrickColor = BrickColor.new("Lime green")
Light2.BrickColor = BrickColor.new("Lime green")
Sound:Play()
TOpen:Play()
wait(1)
Light1.Color = Color3.new(0.372549, 0.368627, 0.368627)
Light2.Color = Color3.new(0.372549, 0.368627, 0.368627)
Bool.Value = true
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
end
end
elseif table.find(PH, item.Name) then
CountBool.Value = true
Prompt1.Enabled = false
Prompt2.Enabled = false
Prompt1e.Enabled = false
Prompt2e.Enabled = false
Light1.BrickColor = BrickColor.new("Really red")
Light2.BrickColor = BrickColor.new("Really red")
Refuse:Play()
wait(1)
Light1.Color = Color3.new(0.372549, 0.368627, 0.368627)
Light2.Color = Color3.new(0.372549, 0.368627, 0.368627)
CountBool.Value = false
Prompt1.Enabled = true
Prompt2.Enabled = true
Prompt1e.Enabled = true
Prompt2e.Enabled = true
end
end
end
return GateModule
Server Script:
local ServerScriptService = game:GetService("ServerScriptService")
local GateModule = require(ServerScriptService.ModuleScript.GateModule)
local Gate = script.Parent
local Reader1 = Gate.Reader1
local Reader2 = Gate.Reader2
local Bool = Gate.Opened
local CountBool = Gate.Countdown
-- Gate Mode
local Door = Gate.Gate
local ExemptDoor = Gate.UG
local Bool = Gate.Opened
local Sound = Door.Open
local Accept = Door.Accept
local Refuse = Door.Refuse
-- Reader's Mode
local Light1 = Reader1.Light
local Light2 = Reader2.Light
local Prompt1 = Light1.ID
local Prompt2 = Light2.ID
local Prompt1e = Light1.Hack.Hack
local Prompt2e = Light2.Hack.Hack
-- Tween
local countdown = 6
local TS = game:GetService("TweenService")
local TInfo = TweenInfo.new(6)
local GateOpen = {CFrame = Door.CFrame}
local GateClose = {CFrame = ExemptDoor.CFrame}
local TOpen = TS:Create(Door, TInfo, GateOpen)
local TClose = TS:Create(Door, TInfo, GateClose)
-- Functions
local function AcessHandler()
GateModule.EventInspection(player,Refuse,CountBool,Prompt1,Prompt2,Prompt1e,Prompt2e,Accept,Light1,Light2,Sound,TOpen,Bool,TClose)
end
local function HackHandler()
GateModule.HackInspection(player,Refuse,CountBool,Prompt1,Prompt2,Prompt1e,Prompt2e,Accept,Light1,Light2,Sound,TOpen,Bool,TClose)
end
Prompt1.Triggered:Connect(AcessHandler)
Prompt2.Triggered:Connect(AcessHandler)
Prompt1e.Triggered:Connect(HackHandler)
Prompt2e.Triggered:Connect(HackHandler)