You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Right now, I’m starting with a simple task: trying to move something up and down based on a MeshPart vertex’s Y position, like a ball in the ocean.
-
What is the issue? Raycast does not detect new vertices created. Maybe EditableMesh needs an update Physics function, as we see in the image below:
The triangle wave-looking mesh with blue details is the ocean project mesh, and the yellow ball is the origin vector for the raycast, while the red one is the final vector of the raycast. As we can see in this script:
local origin = Vector3.new(-310.75, 6, -132.25)
local direction = Vector3.new(-310.75, -6, -132.25)
local rayDirection = direction - origin
local oceanMesh = script.Parent
wait(2)
if oceanMesh then
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.FilterDescendantsInstances = {oceanMesh}
local result = workspace:Raycast(origin, rayDirection, raycastParams)
if result then
local hitPosition = result.Position
-- Visualizar o ponto de impacto com uma esfera
local hitMarker = Instance.new("Part")
hitMarker.Shape = Enum.PartType.Ball
hitMarker.Name = "Mario"
hitMarker.Position = hitPosition
hitMarker.Size = Vector3.new(1, 1, 1)
hitMarker.Anchored = true
hitMarker.BrickColor = BrickColor.Red()
hitMarker.Parent = workspace
print("Hit part: " .. result.Instance.Name)
print("Hit position: " .. tostring(hitPosition))
return result
else
local startPos = Instance.new("Part")
startPos.Shape = Enum.PartType.Ball
startPos.Name = "StartMark"
startPos.Position = origin
startPos.Size = Vector3.new(1, 1, 1)
startPos.Anchored = true
startPos.BrickColor = BrickColor.Yellow()
startPos.Parent = workspace
local endPos = Instance.new("Part")
endPos.Shape = Enum.PartType.Ball
endPos.Name = "EndMark"
endPos.Position = direction
endPos.Size = Vector3.new(1, 1, 1)
endPos.Anchored = true
endPos.BrickColor = BrickColor.Red()
endPos.Parent = workspace
print("No hit")
end
else
print("Ocean part not found in workspace.")
end
-
What solutions have you tried so far? Another way to do what I’m trying to achieve is by using FindClosestVertex, but I don’t want to. I forgot to mention that the MeshPart is not originally a plane; it is a cube that has had its vertices modified and turned into a plane with 10k triangles, as shown in this image:
and when the script runs:
What i tried so far.
I tested placing the raycast in the same location as the original cube, and somehow it detected a ghost cube there. So I can assume that the hitbox is not updating when creating the new vertices, maybe because EditableMesh is still a beta version.
Thanks to anyone who is helping me with this.


