#some module tings please help im just getting into dis part
1 messages · Page 1 of 1 (latest)
PlotService ==> ```local PModule = {}
PModule.__index = PModule
local Functions = require(script.Functions)
function PModule.new(Player: Player)
local self = setmetatable({}, PModule)
--define player
self.Player = Player
self.ActiveGenerators = {}
-- define plot
self.Plot = game.Workspace.Plots:WaitForChild("Empty")
-- assign plot
self.Plot.Name = Player.Name
self.Plot.Owner.Value = self.Plot.Name
self.Plot.Sign.SurfaceGui.TextLabel.Text = Player.Name .. "'s Plot"
--tp player to plot
self.Player.CharacterAdded:Connect(function(Char)
local hrp = Char:FindFirstChild("HumanoidRootPart")
Char:PivotTo(CFrame.new(self.Plot.Teleporter.Position))
end)
Functions.LockSetup(self.Plot, self.Plot.LockPart, self.Plot.Barrier)
end
return PModule```
Functions ==> ```local Module = {}
local function switchCollision(Boolean, Barrier: Folder)
if not Barrier then
warn("Barrier is nil")
end
for i, v in Barrier:GetChildren() do
if v.Name == "RealBarrier" then
v.CanCollide = Boolean
else
v.CanCollide = Boolean
v.Transparency = (Boolean == true) and 0.5 or 1
end
end
end
function Module.LockSetup (Plot: Model, LockPart: Part, Barrier: Folder)
local Billboard = LockPart.BillboardGui
local Status: TextLabel = Billboard.Status
local Timer: TextLabel = Billboard.Timer
Billboard.Enabled = true
Status.Changed:Connect(function()
if Status.Text == "Unlocked" then
switchCollision(false)
else
switchCollision(true)
end
end)
Status.Text = "Unlocked"
Timer.Text = ""
LockPart.Touched:Connect(function(otherPart)
if otherPart.Parent.Name ~= Plot.Owner.Value then return end
if Status.Text == "Unlocked" then
Plot:SetAttribute("Locked", true)
Status.Text = "Locked"
spawn(function()
for i = 1, 60, -1 do
Timer.Text = i
task.wait(1)
end
Plot:SetAttribute("Locked", false)
Status.Text = "Unlocked"
Timer.Text = ""
end)
end
end)
end
return Module```
Hierarchy ===>*
Errors ==> 13:32:06.614 ServerScriptService.PlotSystem.PlotService.Functions:8: attempt to index nil with 'GetChildren' - Server - Functions:8
13:32:06.614 Barrier is nil - Server - Functions:5
pls help
it should be defined correctly in the PlotService module as self.Plot.Barrier
But I cant get the children of it
so im not sure how to index it
i have like 30 lasers which i need to filter
and without the for i, v in balbs:GetChildren() do if v.Name = "thing i need" then sadasd else make laser transparent end
Since barrier is nil then it wont do anything. when u set switchCollision you only send the boolean but not the barrier
Status.Changed:Connect(function()
if Status.Text == "Unlocked" then
switchCollision(false)
else
switchCollision(true)
end
end)
oh yeah
if Status.Text == "Unlocked" then
switchCollision(false, Barrier: Folder)
else
switchCollision(true, Barrier: Folder)
end
end)```
?
does this send both the parameters
sorry to bother but im not exactly sure where to ask and ai is not useful
yt videos arent that specific either
Status.Changed:Connect(function()
if Status.Text == "Unlocked" then
switchCollision(false, Barrier)
else
switchCollision(true, Barrier)
end
end)
Since you have already defined barrier in locks folder
Yay
?
Learn what? I know how to do OOP
Practice ig but I dont really remember.