Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

It only adds one player to the table and stops! Is there a simpler way to do this?

If two players enter at any time, it only adds one person to the queue and only adds the other when the person added leaves! This is just a chunk of a script that teleports everyone that touches a specific part to a private server.

local QueuePart = workspace.queue.QueuePart
local Players = game:GetService("Players")
local pgroup = {}

function AddToQueue(hit)
	if hit.Name == "HumanoidRootPart" and not teleporting then
		hit.Parent.Humanoid.WalkSpeed = 10
		UpdatePlyCount(1)
		local player = Players:GetPlayerFromCharacter(hit.Parent)
		UpdateList(player, true)
		print("Adding "..player.Name.." to the queue...")
		table.insert(pgroup, #pgroup+1, player)
		print("People in queue:"..#pgroup)
	end
end

function RemoveFromQueue(hit)
	if hit.Name == "HumanoidRootPart" then
		hit.Parent.Humanoid.WalkSpeed = 16
		local player = Players:GetPlayerFromCharacter(hit.Parent)
		UpdateList(player, false)
		UpdatePlyCount(-1)
		print("Removing "..player.Name.." from the queue...")
		table.remove(pgroup, table.find(pgroup, player))
		print("People in queue:"..#pgroup)
	end
end

QueuePart.Touched:Connect(AddToQueue)
QueuePart.TouchEnded:Connect(RemoveFromQueue)

1 comment

0

i could upload the full script if you guys want

1 answer

Just do:

pgroup[player.Name] = true

To make it show on table. To remove:

pgroup[player.Name] = nil

This discussion is preserved as it was. New answers, comments, and votes are closed.