-
What do you want to achieve? I’m making a story game so I’m trying to make a queue system
-
What is the issue? When 1 player enters it, it works fine. But when another player tries to enter it, it breaks and starts removing random players
-
What solutions have you tried so far? I’ve tried to debug it but nothing happens, it doesnt give an error too
This is my modulescript:
local Region3M = {}
function Region3M:ReturnTouchingParts(Object)
local PartRegion = Region3.new(Object.Position - Object.Size/2, Object.Position + Object.Size/2)
return workspace:FindPartsInRegion3(PartRegion, Object)
end
return Region3M
and this is my script:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local MGame = workspace.Game
local Region3Module = require(script.Region3)
local Region = MGame.Region
local Highlight = MGame.Highlight.Highlight
local SurfaceUI = MGame.Highlight.SurfaceUI
local Count = SurfaceUI.Count
local MaxCount = 6
local Queue = {}
local CountdownNumber = 15
local CountdownStartTick;
local GetCountdown = function()
return CountdownNumber - (math.floor(tick() - CountdownStartTick))
end
while true do
local Objects = Region3Module:ReturnTouchingParts(Region)
for Index, Player in pairs(Queue) do
if not Player.Character then
table.remove(Queue, Index)
continue
end
if not table.find(Objects, Player.Character.PrimaryPart) then
table.remove(Queue, Index)
end
end
for _, Object in pairs(Objects) do
if Players:GetPlayerFromCharacter(Object.Parent) and Object == Object.Parent.PrimaryPart then
local Player = Players:GetPlayerFromCharacter(Object.Parent)
if not table.find(Queue, Player) and #Queue < MaxCount then
table.insert(Queue, Player)
print("Added!")
end
end
end
if #Queue > 0 and not CountdownStartTick then
CountdownStartTick = tick()
elseif #Queue == 0 then
CountdownStartTick = nil
SurfaceUI.Count.Text = #Queue.." / "..MaxCount
end
if CountdownStartTick and GetCountdown() > 0 then
SurfaceUI.Count.Text = #Queue.." / "..MaxCount.."\n"..GetCountdown()
end
if #Queue >= 0 and #Queue < MaxCount then
Highlight.FillColor = Color3.fromRGB(0, 255, 0)
elseif #Queue == MaxCount then
Highlight.FillColor = Color3.fromRGB(255, 0, 0)
end
if CountdownStartTick and GetCountdown() == 0 then
SurfaceUI.Count.Text = "Teleporting..."
Highlight.FillColor = Color3.fromRGB(255, 0, 0)
local Server = TeleportService:ReserveServer(12153090763)
TeleportService:TeleportToPrivateServer(12153090763, Server, Queue)
Queue = {}
task.wait(5)
end
task.wait()
end
Can someone help me? I’ve tried all the solutions I can but nothing works.
I can provide a rblx copy of my place if you want