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

Detecting players in a block/touching it ?

How would I detect the amount of players in a block or between 8 points and check the team color to see if teams are equal or teams unequal. I'm confused on this subject.

2 comments

0

There are multiple ways of doing this I can think of. You could use Touched and TouchEnded to track touch or FindPartInRegion3 plus getPlayerFromCharacter. Going to implement both and will be right back with the asnwer.

0

Try looking at the player's properties. I think "DistanceFromPlayer" would help.

1 answer

✓ Accepted answer

Implemented this, worked just fine in local server. You could also use FindPartsInRegion3

players = {}

script.Parent.Touched:connect(function(part)
	if part.Parent and part.Parent:FindFirstChild("Humanoid") then
		players[part.Parent.Name] = true
	end
end)

script.Parent.TouchEnded:connect(function(part)
	if part.Parent and part.Parent:FindFirstChild("Humanoid") then
		players[part.Parent.Name] = false
	end
end)

while wait(5) do
	local names = {}
	for k,v in pairs(players) do
		if v then
			table.insert(names, k)
		end
	end
	print(table.concat(names, ", "))
end

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