Looking on the wiki it does not appear that there is a direct event that fired when a region3 is touch or entered. So I’m pretty sure the only way to do this is set up a loop that calls the workspace:FindPartsInRegion3 function and get the return values. If you wanted you could hook the function up to an event so that when a part is found, it fires a remote to all the clients.
heres the wiki class if you want to check it out, there aren’t too many properties or functions.
@Planet_Dad if you wish to let the server know what the user is touching just do the region3 serverly and then do Region3withwhitelist. and then whitelist everycharacter go through the list that it returns and check for any humanoidrootparts then get the player by Game.Players:GetCharacter(HumanoidRootPart.Parent)
Touched is 100% reliable, depending on which enviroment you use it on. On the client it is far more “reliable”, the server sometimes misses some events due to latency and other reasons. TouchEnded however is extremely unreliable, and I would recommend using math if you need to use TouchEnded.
Some examples of math you could use is Magnitude or some formulas.
Yes for what you’re doing it doesn’t sound like TouchEnded is a good choice. A simple Region3 while loop as others have mentioned would be fine, I wouldn’t bother with connecting it with heartbeat cause a tiny bit of lag isn’t going to matter over a map voting pad. OverHash’s idea with Magnitude would also work, though if you choose this I would make sure your button is a circle.
TouchEnded tends to fire randomly even when player’s are still touching the part. If I remember right animations tend to mess it up including idle animations. You could always try it out for yourself of course in studio.
EDIT: It has come to my attention that people are liking this post. The code below does not work correctly, because it creates a region3 everytime the part is touched, instead of creating the regions once and referencing them.
DO NOT use the code below. Let me be clear, do not use the code. Region3’s are perfectly fine.
This is what I am using for my game. It creates a Region3 when a part in a table is touched, and checks if whatever touched it is still touching using FindPartsInRegion3. If the table of parts in the Region3 is nil, then the loop for checking stops until the next touch. I edited it a little bit without testing, but I think it should work still. The whitelist is where you would keep the part that touches the other part.
local TableOfParts = FolderOfParts:GetChildren()
for _,v in pairs(TableOfParts) do
v.Touched:Connect(function(ThingThatTouchedOneOfTheParts)
local CurrentWater = v
local Min = CurrentWater.Position - (0.5 * CurrentWater.Size)
local Max = CurrentWater.Position + (0.5 * CurrentWater.Size)
local Region = Region3.new(Min,Max)
local Whitelist = {CertainPart}
while wait(.1) do
local CheckField = workspace:FindPartsInRegion3WithWhiteList(Region, Whitelist)
if CheckField[1] == nil then
else
end
end
end
else
end
else
end
end)
end
Maybe not the most efficient, but it’s reliable.
NodeSupport , you are one of the Smartest People in the Entire Universe. I just Used this Method. Its Great! If I could Award you with A Badge , I would!