I have recently made a Building system but for some reason it flys towards the camera. I have spent hours trying to fix this error with no success.
https://gyazo.com/09df3bb688d3a81e47edbe75880a044e
Here is my code:
local mouse = game.Players.LocalPlayer:GetMouse()
local Model = workspace:WaitForChild('Window1')
local posX = mouse.Hit.X
local posY = mouse.Hit.Y
local posZ = mouse.Hit.Z
local function Snap()
posX = math.floor(mouse.Hit.X)
posY = mouse.Hit.Y
posZ = math.floor(mouse.Hit.Z)
end
mouse.Move:Connect(function()
Snap()
Model:SetPrimaryPartCFrame(CFrame.new(posX, posY + 3.7, posZ))
end)
local function Place()
local WindowCopy = game:GetService('ReplicatedStorage').Objects.Window1:Clone()
WindowCopy.Parent = workspace
WindowCopy:SetPrimaryPartCFrame(CFrame.new(posX, posY + 3.7, posZ))
end
mouse.Button1Down:Connect(function()
Place()
end)
Thanks

2 comments
Thanks So much! It Worked
Make sure to accept answers that work. So that others know that it works as well as to reward the person who answered.