I am trying to make the table shift (move the other values up) when I remove a value, however its not working.
I have tried making the value stored a string instead of instance but it didn’t fix the problem.
My code:
local inLine = {}
-- When you enter the line --
script.Parent.Start.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if table.find(inLine,plr.Name) then
print("Already in line. Ignoring.")
else
if #inLine == 8 then
print("Max amount of players in line!")
else
if plr:FindFirstChild("BypassStart") then
return
else
table.insert(inLine,plr.Name)
local amtInLine = #inLine
controlGui("give",plr)
while wait(.01) do
if table.find(inLine,plr.Name) then
-- To keep the player's position up-to-date :)
local plrsPlaceInLine = table.find(inLine,plr.Name)
plr.Character.Humanoid:MoveTo(script.Parent.Spots:FindFirstChild(plrsPlaceInLine).Position)
end
end
end
end
end
end
end
end)
-- When someone lets you out of the line --
script.Parent.End.ClickDetector.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(groupID) >= rankID then
local nextPlayer = inLine[1]
local playerInstance = game.Players:FindFirstChild(nextPlayer)
print(inLine[1])
print(inLine[2])
local bypassStart = Instance.new("BoolValue")
bypassStart.Name = "BypassStart"
bypassStart.Parent = playerInstance
bypassStart.Value = true
playerInstance.Character.Humanoid:MoveTo(script.Parent.End.Position)
local int = table.find(inLine,nextPlayer)
table.remove(inLine,int)
controlGui("remove",game.Players:FindFirstChild(nextPlayer))
wait(1)
plr["BypassStart"]:Destroy()
end
end)
When I try to print playerInstance it apparently doesn’t exist (argument 1 missing or nil) which would mean that nextPlayer doesn’t exist which would mean the 1st value in the table is nil which would mean the table is not shifting how it should.