So i have a non collide part that detects how many players there are inside and gets put inside a table, but when i jump it removes me from the table.
my script:
local Players = game:GetService("Players")
local Character
local debounce = true
local GTP = {}
local ATP = {}
Players.PlayerAdded:Connect(function(player)
Character = player.Character or player.CharacterAdded:Wait()
end)
local part = script.Parent;
local debounce = true
part.Touched:connect(function(hit)
if debounce == true then
debounce = false
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player and not table.find(GTP ,Player.Name) and Player.TeamColor == BrickColor.new("White") then
table.insert(GTP, Player.Name)
elseif Player and not table.find(ATP ,Player.Name) and Player.TeamColor == BrickColor.new("Bright red") then
table.insert(ATP, Player.Name)
end
wait(1)
debounce = true
else
return false;
end
end)
part.TouchEnded:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player and table.find(GTP ,Player.Name) and Player.TeamColor == BrickColor.new("White") then
table.remove(GTP, table.find(GTP, Player.Name))
elseif Player and table.find(ATP ,Player.Name) and Player.TeamColor == BrickColor.new("Bright red") then
table.remove(ATP, table.find(ATP, Player.Name))
end
end)
while true do
print ("["..#GTP.."]".." GER - USA ".."["..#ATP.."]" )
task.wait(0.5)
end