- What do you want to achieve?
I am trying to add a thumbnail if a player hits a part and if he leaves the part.
I want it to delete the thumbnail that the player made.
- What is the issue? Include screenshots / videos if possible!
Making the thumbnail is working and deleting works also. with 1 player.
If 2 players hit the part it shows 2 thumbnails. but it looks like player 2 deletes player 1’s thumbnail.
I Made the thumbnail.name the name of the player who adds it.
Is this the right way? or should i use the userId?
And how do i get the right thumbnail to be deleted?
local queuePart = workspace.TenPlayers.QueuePart
local panel = workspace.TenPlayers.Panel.SurfaceGui.Frame
local StartP1 = workspace.TenPlayers.Start.StartP1
local StartP2 = workspace.TenPlayers.Start.StartP2
local StartP3 = workspace.TenPlayers.Start.StartP3
local StartP4 = workspace.TenPlayers.Start.StartP4
local StartP5 = workspace.TenPlayers.Start.StartP5
local StartP6 = workspace.TenPlayers.Start.StartP6
local StartP7 = workspace.TenPlayers.Start.StartP7
local StartP8 = workspace.TenPlayers.Start.StartP8
local StartP9 = workspace.TenPlayers.Start.StartP9
local StartP10 = workspace.TenPlayers.Start.StartP10
local Queue = {}
local MinQueue = 1
local MaxQueue = 10
local playersInQueue = workspace.TenPlayers.playersInQueue
local queueClosed = workspace.TenPlayers.queueClosed
local alreadyExists = false
local function updateGui()
local MinQueueValue = MinQueue - #Queue
panel.StatusQueue.Text = "Wait for at least " ..MinQueueValue.. " players and 30 sec."
if panel.StatusQueue.Text == "Wait for at least 0 players and 30 sec." then
panel.StatusQueue.Text = "Game starts with " ..#Queue.. " players and 30 sec."
end
panel.QueueLabel.Text = "Players in Queue: " ..#Queue.. " /" ..MaxQueue
end
local function Teleport(player, position)
player.Character.HumanoidRootPart.CFrame = position.CFrame
end
local function onPartTouched(touchingPart)
local humaniod = player.Parent:FindFirstChildWhichIsA("Humanoid")
if touchingPart.Name == "UpperTorso" then
wait(1)
for i=1,#Queue do
if Queue[i] == player then
alreadyExists = true
end
end
if alreadyExists == false then
if playersInQueue.Value < MaxQueue then
table.insert(Queue, player.Parent)
playersInQueue.Value = playersInQueue.Value + 1
print(Queue)
updateGui()
local plr = game.Players:GetPlayerFromCharacter(player.Parent)
local userId = plr.userId
local thumType = Enum.ThumbnailType.AvatarBust
local thumSize = Enum.ThumbnailSize.Size48x48
local content = game.Players:GetUserThumbnailAsync(userId, thumType, thumSize)
local newFrameImg = game.ReplicatedStorage:WaitForChild("PlayerImage"):Clone()
newFrameImg.Image = content
newFrameImg.Position = UDim2.new(newFrameImg.Position.X.Scale + (0.1 * #game.Workspace.TenPlayers.Panel.SurfaceGui.Queue:GetChildren()), 0, 0, 0)
newFrameImg.Name = plr.Name
newFrameImg.Parent = game.Workspace.TenPlayers.Panel.SurfaceGui.Queue
end
if playersInQueue.Value == MinQueue then
--Start Time 30sec.
--After timer Teleport to StartP*
end
if playersInQueue.Value == MaxQueue then
queueClosed.Value = true
end
end
end
end
local function onPartTouchEnded(touchingPart)
local humaniod = player.Parent:FindFirstChildWhichIsA("Humanoid")
if touchingPart.Name == "UpperTorso" then
wait(1)
for i=1,#Queue do
if Queue[i] == player.Parent then
alreadyExists = true
end
end
if alreadyExists == true then
local frame = workspace.TenPlayers.Panel.SurfaceGui.Queue:FindFirstChildOfClass("ImageLabel")
for i, v in pairs(Queue) do
if frame.Name == v.Name and frame.Name == player.Parent.Name then
frame:Destroy()
table.remove(Queue, #Queue)
playersInQueue.Value = playersInQueue.Value - 1
updateGui()
end
end
alreadyExists = false
end
print("Left Queue")
end
end
queuePart.Touched:Connect(onPartTouched)
queuePart.TouchEnded:Connect(onPartTouchEnded)