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

How do you create regions without region3 ?

local region = Region.new(min , max)
--is there another way to do this

1 comment

0

Part:GetTouchingParts() can be used as an alternative ig. But why not just use Region3 tho? Don't be afraid, it's really not that complicated.

1 answer

Hmmm...

This is my initial thought... This can be very unreliable tho, why not just use the real Region3? Don't be afraid, it's really not that complex.

A good tutorial: https://www.youtube.com/watch?v=XAwoodFJWos

Anyways...

local part = script.Parent --gets the part

local inRegion = {} --table of character/s inside the part

part.Touched:Connect(function(hit) --detects if a part is touched
	local character = hit.Parent --gets the character who touched
	local humanoid = character:FindFirstChild("Humanoid") --gets the humanoid of it
	
	if humanoid and not table.find(inRegion, character) then --checks if humanoid exists and if the character is not in the table yet
		table.insert(inRegion, character) --inserts the character to the table
	end
end)

part.TouchEnded:Connect(function(hit) --detects if a part is untouched
	local character = hit.Parent
	local humanoid = character:FindFirstChild("Humanoid")

	if humanoid and table.find(inRegion, character) then --checks if humanoid and the character is in the table
		for i = 1, #inRegion do --loops through the table
			if inRegion[i] == character then --checks if character
				table.remove(inRegion, i) --removes it
			end
		end
	end
end)

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