I’m trying to make a simple TP Pad system, with an indicator showing how many players are in the tp.
I keep getting line 29 errored, saying "invalid argument #2 to 'remove' (number expected, got string)
local players = game:GetService("Players")
local part = script.Parent
local val = part.amount
local amount = val.Value
local gui = part.BillboardGui.TextLabel
local plrs = part.BillboardGui.plrs
local touching = {}
part.Touched:Connect(function(hit)
if amount < 4 then
if players:GetPlayerFromCharacter(hit.Parent) then
local plr = players:GetPlayerFromCharacter(hit.Parent)
if plr and not table.find(touching,plr.Name) then
table.insert(touching,plr.Name)
amount = amount +1
gui.Text = amount.."/4"
end
end
end
end)
part.TouchEnded:Connect(function(hit)
if players:GetPlayerFromCharacter(hit.Parent) then
local plr = players:GetPlayerFromCharacter(hit.Parent)
if plr and table.find(touching,plr.Name) then
for i, v in ipairs(touching) do
if v == plr.Name then
table.remove(touching, i) --Line 29
amount = amount -1
gui.Text = amount.."/4"
return
end
end
end
end
end)
What’s wrong? What do I do?