Model not following mouse

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want the model to follow the cursor when it hovers the gridparts.

  2. What is the issue? It doesn’t seem to follow the cursor. [video]

  3. What solutions have you tried so far? I tried looking for posts similar to this, but most of them are not applicable to my situation.

local model = game.ReplicatedStorage["Basic Cubicle"]

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


mouse.Move:Connect(function()
	local raycastresult = workspace:Raycast(mouse.Hit.Position + Vector3.new(0,150,0),Vector3.new(0,-250,0))
	if raycastresult ~= nil then -- 
		if raycastresult.Instance.Name == "GridPart" then 
			print(raycastresult.Instance.Name) -- WORKS
			model:SetPrimaryPartCFrame(CFrame.new(raycastresult.Instance.Position))
		end
	end
end)

mouse.Button1Down:Connect(function()
	local raycastresult = workspace:Raycast(mouse.Hit.Position + Vector3.new(0,150,0),Vector3.new(0,-250,0))
	if raycastresult.Instance.Name == "GridPart" then
		local p = model:Clone()
		p.Parent = workspace
		p:SetPrimaryPartCFrame(CFrame.new(raycastresult.Instance.Position))
	end
end)

Your not using the raycast data to position the model, you’re using the position of the object that was hit.

Even if I use the raycast data’s position, it still doesn’t work. Can you help?

It could be because your “SetPrimaryPartCFrame” (which is depricated, use :PivotTo) is taking in .Position wrather then .CFrame?

CFrame allows you give it a Vector3 value, like so:

CFrame.new(Vector3.one)

My apologies for the lack of knowledge, thank you for letting me know.

Its a bit of a obscure thing so its fine