I am trying to make a gear that when you click a part follows your cursor but it keeps erroring
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
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.
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
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.