Hello! I just need to know if TouchEnded is detecter when a touched part is destroy? Could you answer me please?
Why would it work when the part is destroyed? It would require a physics change to detect a Touched/TouchEnded, and I don’t think setting the parent of the part to nil
would be a physics change,
Also, this’d be an easy thing to test out yourself without necessarily making a post about it, just go on Studio, make a part that gets destroyed, make a TouchEnded event that print something, stand on it, and see what happens with TouchEnded when the part is gone
I have another question. How to detect how many players there are in a zone?
Use FindPartsInRegion3
and give it the region you want to find parts in and confirm those parts belong to a player
1 Like
But It is a really big region with at last 1000 parts. Are you sure this will work correctly.
I’m not completely sure about that, someone else may have a proper answer to this 2nd questionthat doesn’t really have any relation to the question in the post
If I ask all this questions, it is to make the same thing. I would like know fastly how many players there are in a region.
One potential solution involves using RunService.Heartbeat
to check if the Character’s HumanoidRootPart is within the bounds of certain coordinates:
Touched/TouchEnded have been pretty unreliable in general for humanoids. I would recommend something like checking every frame which players are in the area of the zone.
local function isPointInZone(point, zonePart)
local relPoint = zonePart.CFrame:PointToObjectSpace(point)
return math.abs(relPoint.X) < zonePart.Size.X * 0.5 and math.abs(relPoint.Z) < zonePart.Size.Z * 0.5
end
local playersInZone = {}
local function onHeartbeat(dt)
for i, player in pairs(game.Players:GetPlayers()) …
More info around this subject can be found in the following posts:
There pretty self explanatory (kind of), they transform points or vector3s into either WorldSpace or ObjectSpace relative to the CFrames that called them. ObjectSpace (in this case) meaning that the vector3 that you give it (PointToObjectSpace) will become relative to the CFrame that called it. And Worldspace essentially meaning the vector3 that you give it will become relative to 0,0,0 the origin of the world. it will be transformed from object/local space to worldspace.
So, for example, if …
function round(number, to)
to = to or 1
return math.floor(number/to + 0.5) * to
end
function roundVector(vector, unit)
return Vector3.new(round(vector.X, unit), 7--[[vector.Y]], round(vector.Z, unit))
end
local renderStepped = runService.RenderStepped:Connect(function()
if not startedPlacingWall then
local mouseP = mouse.Hit.p
pole1.CFrame = CFrame.new(roundVector(mouseP + Vector3.new(0, pole1.Size.X/2, 0), gridSize))*CFrame.Angles(0, 0, math.rad(90))
else
r…
1 Like