Reference block on building tool going nuts

Hi guys, I’m working on a reference block for a build tool, that shows where you’re about to place a block, however it is VERY glitchy.

Video of issue:

You probably aren’t adding the reference block inside a blacklist

1 Like

That’s most likely it. Any idea how I can do this?

I think it’s probably that the mouse is detecting the Block as well, maybe set the TargetFilter of the mouse in the function to the block after positioning?

local function RefrenceBlock() --Area I need help with
		
	local Block = Instance.new("Part")
	Block.Name = "TempBlock"
	Block.Parent = workspace
	mouse.TargetFilter = Block
	Block.Transparency = 0.5
	Block.Size = Vector3.new(4,4,4)
	Block.CFrame = CFrame.new(round(mouse.Hit.Position,4))
	Block.BrickColor = BrickColor.Blue()
	Block.Anchored = true
	wait(0.00001)
	Block:Destroy()
end
1 Like

Where you are creating the raycast params you add the block to castParams.FilterDescendantsInstances = {player.Character}castParams.FilterDescendantsInstances = {player.Character, [BLOCK]}

1 Like

I will try this right now! Thanks for the help!

You can simply set a new RaycastParams.FilterType. Your code will look like:

local castParams = RaycastParams.new()
RaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
castParams.FilterDescendantsInstances = {player.Character,[BLOCK]}
1 Like

I’ve added the reference block to the blacklist, however it seems like the issue is still somewhat present.

Could it maybe be that you have to set the TargetFilter to the block? Perhaps try what I did, and try both before positioning it and after positioning

1 Like

Same issue. Also seems like the block;
A: Fly’s into the camera’s direction
B: Disappears when the curser stops moving

Most definitely the issue comes from the fact that the mouse is detecting the block when it shouldn’t. And it stops when you dont move the mouse because the Move event only happens when the mouse is moved. What you could maybe do is have a folder somewhere, set the TargetFilter of the mouse to that folder, and when you have to parent the BLock, parent it to that folder, maybe that could work?

1 Like

I’m looking through the use of Mouse, and I cannot find another method to use other than Mouse.Move. Also, I made the folder, and I have the same result.

I think I might’ve found a solution. Instead of making multiple instances and deleting them, I might be able to just change the position of it.

Thanks to everyone above this reply for all the help!

1 Like