Im in the process of making a queue system. When i add a player to the queue. When there are two people in the queue, it works but deletes it a split second after. How the system works is it gets the players username and id, puts it in a table and clones a frame from replicated storage. The frame is named after the players id. Here is the script:
local players = {}
local frames = {}
local newValue --6436346
local isfinished = false
game.ReplicatedStorage.GetQueue.OnClientEvent:Connect(function(requests, currentid, targetusername, isrunning) --requests = holding multiple players' id's. targetusername = username
local v = requests[#requests]
print(requests[#requests])
isfinished = false
print(requests)
table.insert(players, v)
print(script.Parent.Frame.Frame.Folder:GetChildren())
print(players)
local clone = game.ReplicatedStorage.QueueExample:Clone()
clone.Name = players[#players]
newValue = players[#players]
clone.Username.Text = targetusername
clone.Parent = script.Parent.Frame.Frame.Folder
print(script.Parent.Frame.Frame.Folder:GetChildren())
print(players)
--======MAIN=======
for index,value in pairs(players) do
print("Value : "..value)
print("here!")
print(players[table.find(players, value)], newValue)
if players[table.find(players, value)] ~= newValue then
print("NO!")
print(players)
print(players[table.find(requests, players)], "old: "..value)
print(#players)
script.Parent.Frame.Frame.Folder:FindFirstChild(players[table.find(players, value)]):Destroy()
print(players[index])
print(players, value)
print("set to nil")
print(script.Parent.Frame.Frame.Folder:GetChildren())
table.remove(players, index)
print(script.Parent.Frame.Frame.Folder:GetChildren())
print(players)
else
end
end
--======MAIN======================
Output:
16:37:18.380 Avatar Loading System @ 07 Oct 2021 16:37 auto-recovery file was created - Studio - C:/Users/alexh/Documents/ROBLOX/AutoSaves
16:37:28.384 Running Properly - Server - AvatarsLoading:18
16:37:28.437 247535 - Client - LocalScript:7
16:37:28.437 {…} - Client
16:37:28.437 ▼ {
[1] = UIListLayout
} - Client
16:37:28.437 {…} - Client
16:37:28.438 ▼ {
[1] = UIListLayout,
[2] = 247535
} - Client
16:37:28.438 {…} - Client
16:37:28.439 Value : 247535 - Client - LocalScript:24
16:37:28.439 here! - Client - LocalScript:25
16:37:28.439 247535 247535 - Client - LocalScript:26
16:37:29.785 cleared - Server - AvatarsLoading:31
16:37:31.186 1320922 - Client - LocalScript:7
16:37:31.186 {…} - Client
16:37:31.186 ▼ {
[1] = UIListLayout,
[2] = 247535
} - Client
16:37:31.187 {…} - Client
16:37:31.187 ▼ {
[1] = UIListLayout,
[2] = 247535,
[3] = 1320922
} - Client
16:37:31.188 {…} - Client
16:37:31.188 Value : 247535 - Client - LocalScript:24
16:37:31.188 here! - Client - LocalScript:25
16:37:31.188 247535 1320922 - Client - LocalScript:26
16:37:31.189 NO! - Client - LocalScript:28
16:37:31.189 {…} - Client - LocalScript:29
16:37:31.189 nil old: 247535 - Client - LocalScript:30
16:37:31.189 2 - Client - LocalScript:31
16:37:31.190 247535 - Client - LocalScript:33
16:37:31.190 {…} 247535 - Client - LocalScript:35
16:37:31.190 set to nil - Client - LocalScript:37
16:37:31.190 ▼ {
[1] = UIListLayout,
[2] = 1320922
} - Client - LocalScript:38
16:37:31.190 ▼ {
[1] = UIListLayout,
[2] = 1320922
} - Client - LocalScript:40
16:37:31.191 ▼ {
[1] = 1320922
} - Client - LocalScript:42
16:37:41.301 table removed - Server - AvatarsLoading:52
16:37:42.318 Put in queue - Server - AvatarsLoading:96
16:37:43.401 Running Properly - Server - AvatarsLoading:18
16:37:44.601 cleared - Server - AvatarsLoading:31
16:37:46.441 Humanoid::ApplyDescription() Failed to load Pants, default applied - Studio
16:37:58.717 table removed - Server - AvatarsLoading:52
16:43:57.478 Avatar Loading System auto-recovery file was created - Studio - C:/Users/alexh/Documents/ROBLOX/AutoSaves