Part Going To Camera

I tried to make the part follow the player’s mouse but this happened:


Here’s the code:

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()

local mouse = plr:GetMouse()
local part = Instance.new("Part",workspace)
while wait() do
	
	part.Anchored = true
	part.Transparency = 0.4
	part.CFrame = CFrame.new(mouse.Hit.Position)
	
	mouse.Button1Down:Connect(function()
		
		part.Anchored = false
		part.CFrame = CFrame.new(mouse.Target.Position)
	end)
	
end

Any help is appreciated!

TargetFilter

mouse.TargetFilter = part

https://create.roblox.com/docs/reference/engine/classes/Mouse#TargetFilter

That worked! Can you please explain what it does?

It makes it so the Mouse ignores the Part when making colculations

1 Like

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