Mouse.Target and Ray not detecting certain faces of placed blocks

image
image

Both these were placed via a build tool

It is also not consistent which side it is

image

here is how I recognize the block:

runService.Heartbeat:Connect(function()
	outline.Adornee = nil
	if equipped then

		if mouse.Target == nil then return end
		if not mouse.Target:IsA("Part") then return end
		if mouse.Target.Locked == true then return end

		outline.Adornee = mouse.Target
		outline.Parent = mouse.Target

	end
end)

and It only doesnt work on one face of it,

here is all the children of the block
image

I tried making a new block, and sizing it the same thing with no children, problem still exists.
so it is not the block nor the children.

bumping this cause the game is still in the background for me and this still isnt fixed
anyone know why it would do this or have any debug ideas?

Try printing the mouse target and seeing if something is blocking the block from your view

1 Like

I’m confused. What are you trying to achieve here? You stated your problem, but I can’t seem to understand what you’re trying to accomplish here.

As @ellienonekomimi has said, you may use print statements to see what Mouse.Target is printing out.

1 Like

“Outline” ty im gonna use this to try to figure it out

pretty sure its clear
its not detecting certain faces of placed blocks
I feel like you could infer I dont want that to happen

Ok so update, Outline isnt a member of the block and the word outline isnt used in any script in the entire place

Oh sorry for the multiple comments but also I couldnt recreate it by placing just one block, I had to spam to place like 15 blocks and then a few of them had the issue, Im confused lol

Can you try using a ray to detect the faces of the placed blocks? For every ray casted, try printing out its Instance and Normal property. Using the Mouse object doesn’t seem to give us the result of the face detected by the mouse.

1 Like

Can you try printing out it’s Parent property? Or have you tried to click the print statement itself when it prints “Outline” in the console to see if your Explorer tab is highlighted?

Instance: “Outline”
Normal: “-1, 0, 0”

OH! I FIXED IT GUYS

so for the build tool I had a outline to show where you would build, cause a script was parented to it the words outline never showed up in any script! im so sorry to inconvienience yall with such a simple problem, I did spend 1 year off of the game cause I had spent weeks debugging lolz

1 Like

I have seen this happen before with parts that were made or resized using building tools… Sometimes one face of a part will not register with Mouse.Target because Roblox is picky about thin parts or edges. It can also happen with unions or meshes if the collision is not precise.

One thing you can try is using your own raycast instead of Mouse.Target. It gives you more control and sometimes fixes this issue.

local userInput = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera

runService.Heartbeat:Connect(function()
    local mousePos = userInput:GetMouseLocation()
    local ray = camera:ViewportPointToRay(mousePos.X, mousePos.Y)

    local params = RaycastParams.new()
    params.FilterType = Enum.RaycastFilterType.Blacklist

    local result = workspace:Raycast(ray.Origin, ray.Direction * 500, params)

    if result and result.Instance:IsA("Part") and not result.Instance.Locked then
        outline.Adornee = result.Instance
        outline.Parent = result.Instance
    else
        outline.Adornee = nil
    end
end)

I am not sure if this will help in your case but it is worth testing. Also check if the part is very thin because that can cause certain faces to not be detected!!!

Hope youll get it fixed soon!!

1 Like

Oh still! thankyou! I will add a check to make sure thin parts work too and use raycasts instead of mouse.target, tysm!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.