Sorry for the lack of code -- I'm new to Roblox Studio and don't really know the correct way to approach this problem, but I have a box where if the player stands on it, it'll add the player's team to an array, and when the player leaves, it'll remove to player's name from the list. I don't know how to create arrays yet and my current code doesn't seem to detect the player effectively. Note that the bottom script doesn't work.
local Part = script.Parent
Part.Touched:Connect(function() end)
local debounce = false
function startcapture(hit)
if not debounce then
debounce = true
if game.Players:FindFirstChild(hit.Parent.Name).Team == game.Teams.Black then
-- Add black to array
else
-- Add red to array
end
wait(1)
debounce = false
end
end
function stopcapture(hit)
if game.Players:FindFirstChild(hit.Parent.Name).Team == game.Teams.Black then
-- Remove black from array
else
-- Remove red from array
end
end
script.Parent.Touched:Connect(startcapture)
script.Parent.TouchEnded:Connect(stopcapture)
There's only 2 teams: Red and Black. The array should look something like {"Red", "Red", "Black", "Black", "Red"} or something like that. For instance, if a black team member is inside the box, it'll add "Black" to the array if the player's team name isn't included already( {"Red", "Red", "Black", "Black", "Black", "Red"} ). When the person leaves, it'll remove the player's corresponding team name from the list ( {"Red", "Red", "Black", "Black", "Red"} ).
I would also like it to return the number of times "Red" shows up and "Black" shows up (I could probably search this up but would really appreciate it if you could do it for me).
Please help me :)
Also please help me answer this question: https://scriptinghelpers.org/questions/115277/how-to-create-a-max-size-limit-for-a-billboard-gui

2 comments
What is the purpose of creating this array? Are you just trying to count how many people from each team are in the region?
Yes