Help With Building System

I am trying to make a gear that when you click a part follows your cursor but it keeps erroring

image

1 Like

Is that a server or local script

Local script cause when I used getmouse on the server it would break.

Can’t you put the two variables outside the block of code? Because sometimes I had that error too and when I moved the variables it worked for me sometimes

Tried it different error now.

maybe listen what the error says? (you need Vector3, not CFrame)

It might be because in:
game.Workspace.Salty:PivotTo(mouse.Hit.CFrame) in line 5 and line 7

But if I do that It’ll error again cause the mouse.hit uses cframe.

image

Is the workspace.Salty a model?

Yes Its a pile of salt I’m trying to make it kind of like Phasmaphobias salt.

In that case, did you set a PrimaryPart?

Try changing line 5 and 7 to:
game.Workspace.Salty:MoveTo(mouse.Hit.Position)

It works but now the model just zooms into the camera

1 Like

Okay let me rewrite you the script

Yes I did set a primaryPart.—

Try this:

game.Parent.Parent.Activated:Connect(function()
	local player = game.Players.LocalPlayer
	local mouse = player:GetMouse()
	
	local function move()
		if mouse.Hit ~= game.Workspace.Salty then
			game.Workspace.Salty:MoveTo(mouse.Hit.Position)
		end
	end
	
	move()
	mouse.Move:Connect(function()
		move()
	end)
end)

It works but when you move it around it zooms to the camera

Is the y position fixed? like does not change?

No It still goes up to the camera maybe if you lock the y position so it don’t go up things.