I have an issue with my queue system
Video below will show what the issue is
Local script:
local frame = script.Parent.Frame
local template = frame.Template
local scroll = frame.ScrollingFrame
local join = frame.Join
local leave = frame.leave
local button = script.Parent.Button
local remote = game.ReplicatedStorage.Queue
local player = game.Players.LocalPlayer
remote.OnClientEvent:Connect(function(table, plr, func)
print(table)
print(table[1])
print(plr.Name)
if string.lower(func) == "join" then
for index, value in table do
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = game.Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
print(index, value)
--[[
local thing2 = Instance.new("Frame")
thing2.Visible = true
thing2.BackgroundTransparency = 1
thing2.Size = UDim2.new(1, 1, 1, 1)
thing2.Name = plr.Name
thing2.Parent = scroll
]]
local thing = template:Clone()
thing.Username.Text = plr.Name
thing.placement.Text = index
thing.Rank.Text = plr:GetRoleInGroup(17100957)
thing.Parent = scroll
thing.Visible = true
thing.Name = plr.Name
thing.UserImage.Image = content
game["Run Service"].Heartbeat:Connect(function()
if not scroll:FindFirstChild(plr.Name) then
return
else
if #scroll:FindFirstChild(plr.Name):GetChildren() > 1 then
--thing2:Destroy()
--remote:FireServer("leave")
end
end
end)
end
end
if string.lower(func) == "leave" then
if not scroll:FindFirstChild(plr.Name) then
return
else
local thing = scroll:FindFirstChild(plr.Name)
thing:Destroy()
end
end
if string.lower(func) == "leaveplrqueue" then
end
end)
player:GetPropertyChangedSignal("Team") :Connect(function()
if not scroll:FindFirstChild(player.Name) then
return
else
local thing = scroll:FindFirstChild(player.Name)
thing:Destroy()
leave.Visible = false
join.Visible = true
end
end)
button.MouseButton1Click:Connect(function()
frame.Visible = not frame.Visible
end)
join.MouseButton1Click:Connect(function()
remote:FireServer("join")
join.Visible = false
leave.Visible = true
end)
leave.MouseButton1Click:Connect(function()
local thing = game.HttpService:JSONDecode(game.StarterGui.QueueTable.Value)
remote:FireServer("leave")
leave.Visible = false
join.Visible = true
end)
Server script
local remote = game.ReplicatedStorage.Queue
local tablePlayer = {
}
remote.OnServerEvent:Connect(function(plr, text, func)
print(text)
if string.lower(text) == "join" then
table.insert(tablePlayer, plr.Name)
print(tablePlayer[1])
remote:FireAllClients(tablePlayer, plr, "join")
end
if string.lower(text) == "leave" then
remote:FireAllClients(tablePlayer, plr, "leave")
--table.remove(tablePlayer, plr.Name)
print(tablePlayer[1])
for i, player in tablePlayer do
table.remove(tablePlayer, i)
print(tablePlayer[1])
remote:FireAllClients(tablePlayer,plr,"leaveplrqueue")
end
end
end)
game["Run Service"].Heartbeat:Connect(function()
game.StarterGui.QueueTable.Value = game.HttpService:JSONEncode(tablePlayer)
end)