I made a hardpoint system, at first it works fine but after you capture the first point a new one doesnt get picked the original one just turns transparent. im also using the zoneplus module here but it seems like it causes a problem when changing points. and only the playerExited is working after capturing the first point. Theres no capturing yet since i just want to make it so that once the player is in the point it gets captured then i add the capturing process after but its not working.
local RS = game:WaitForChild("ReplicatedStorage")
--Modules
local zone = require(RS:WaitForChild("Modules"):WaitForChild("Zone"))
local ZonePlrs = require(game.ServerScriptService.Script.PlrsInZone)
local config = require(script.Config)
--Folders
local PointsFolder = workspace.HardPointFolder
local events = RS:WaitForChild("Events")
--Events
local pointChanged = events:WaitForChild("PointChanged")
local pointCaptured = events:WaitForChild("PointCaptured")
--Points
local points = require(game.ReplicatedStorage.Points)
--Points Vars
local activePoint = nil
local captured = true
local capturing = false
local captureProgress = 0
local curPoint = nil
local capturingPlayersCount = 0
local newpoint = nil
local function activatePoint(point)
if activePoint and captured then
activePoint.Trigger.Transparency = 1
activePoint.Trigger.BrickColor = BrickColor.new("White")
activePoint.Display.BillboardGui.Title.BackgroundColor3 = BrickColor.new("White").Color
activePoint.Display.BillboardGui.Enabled = false
captured = false
end
activePoint = point
activePoint:WaitForChild("Trigger").Transparency = 0.65
activePoint.Display.BillboardGui.Enabled = true
curPoint = point
end
local function SelectPoint()
if captured then
local list = {}
for _, v in ipairs(PointsFolder:GetChildren()) do
if v and v ~= curPoint then
table.insert(list,v)
end
end
local index = math.random(1, #list)
activatePoint(list[index])
print("newpoint Selected")
end
end
SelectPoint()
local newpoint = zone.new(curPoint.Trigger)
newpoint.playerEntered:Connect(function(hit)
print( hit.Name.." has entered")
captured = true
SelectPoint()
end)
newpoint.playerExited:Connect(function(hit)
print(hit.Name.." player has exited")
end)