im trying to make a placement system but this happens
it works fine without the camera being locked to a part
code:
game:GetService("RunService").RenderStepped:Connect(function()
local part = workspace.testblock
local mouse = plr:GetMouse()
mouse.TargetFilter = part
part.CFrame = CFrame.new(mouse.Hit.p.X, part.Position.Y, mouse.Hit.p.Z)
end)
The code you posted is perfectly fine. It seems like a different part of your script is causing the error.
(Minor improvements below)
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local part = workspace:WaitForChild("testblock")
mouse.TargetFilter = part
RunService.RenderStepped:Connect(function()
if mouse.Target then
part:PivotTo(CFrame.new(mouse.Hit.Position))
end
end)
that didnt change anything still does the same glitch when locking the camera to the part (game.Workspace.CurrentCamera.CFrame = game.Workspace.Game.GameCamera.CFrame)
This is happening because your camera positioning is mistimed. You need to set your CameraType to Scriptable. Right now your code is fighting the default camera controls. What happens is you set the camera position, the game renders, the default camera takes control, then you check the mouse position. So your mouse position is coming from the default camera position.