-
What do you want to achieve?
R = Make the exit, enter area works like it should be. -
What is the issue?
R = So, when you enter an area, a bool value will be set on true, telling you that someone is in there with a train, and if you are driving the train, you will get the welcome to station notification.
Everything works fine until you leave the station and the value doesn’t go false, also i added a table that indicates the players that can’t be notified again until they leave the station, so the notification doesn’t repeat infinite times while being at the station, and it removes the players from the table once they are not in a station anymore, but like the value, it doesn’t to his job of removing the players. So when you go to the next station, his own value will go on, but you won’t get the welcome notification now, since you are in the table even if you left the past station, and his own value won’t go off once you are gone.
This occurs when there is more than 1 station in the station folder. If there is only 1 station, the system works fine.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
R = Trying to change tables position, making another functions.
Here is my code:
-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Folders
local Modulos = ReplicatedStorage.Modulos
local Eventos = ReplicatedStorage.Eventos
-- Eventos
local Notificacion = Eventos.Notificacion
-- Parts
local Script = script.Parent
local Estaciones = Script.Estaciones
local DBOS = Estaciones.DBOS
local MensajeDeLlegada = "Mantente en la estacion hasta que el sonido DBO lo indique y puedas avanzar."
-- Table
local n = {}
-- Variables
local function RemoveVal(tbl, val)
for i,v in pairs(tbl) do
if v == val then
table.remove(tbl,i)
break
end
end
end
function getPlayersInRegion()
for i,e in Estaciones:GetChildren() do
if e:IsA("Folder") and e.Name ~= "DBOS" then
local Estacion = e
local DetectArea = nil
local parts = nil
local DBOController = nil
local DBOBVCDA = nil
if Estacion:FindFirstChild("DBOCDAzteca") then
local r = {}
local t = {}
DetectArea = Estacion:FindFirstChild("DBOCDAzteca")
parts = workspace:GetPartsInPart(DetectArea)
DBOController = DBOS:FindFirstChild(Estacion.Name)
DBOBVCDA = DBOController.CDAzteca
for i, v in pairs(parts) do
if v.Parent ~= nil then
if not table.find(t, v.Parent.Parent.Parent) then
local Train = v.Parent.Parent.Parent
if Train ~= nil and Train.Name == "TRAIN" then
table.insert(t, Train)
end
end
end
end
for i, player in t do
if not table.find(r, player) then
DBOBVCDA.Value = true
if player:FindFirstChild("Dueño") then
local Owner = player:FindFirstChild("Dueño")
if Owner.Value ~= nil and not table.find(n, Owner.Value) then
table.insert(n, Owner.Value)
Notificacion:FireClient(Owner.Value, "Llegando a: "..Estacion.Name, MensajeDeLlegada, 7, "http://www.roblox.com/asset/?id=8076588158")
end
end
end
end
for i, player in r do
if not table.find(t, player) then
RemoveVal(n, player)
DBOBVCDA.Value = false
end
end
r = t
end
end
end
end
task.spawn(function(Check)
while task.wait() do
local Players = getPlayersInRegion()
end
end)
I hope you can help me with this little issue, i would thank you!