local p = game.Players.LocalPlayer local m = p:GetMouse() m.Button1Down:Connect(function() local p = Instance.new("Part") p.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Head.CFrame * m.Hit.LookVector*2) p.Parent = workspace end)
When I click, it places itself correctly for a bit, after walking around a little bit, it suddenly spawns at random positions. How would I fix this?
From what it looks like, you are trying to place the part where you click. All you have to do is set the parts position to mouse.Hit.p
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local mouse = player:GetMouse() mouse.Button1Down:Connect(function() local part = Instance.new("Part") part.Position = mouse.Hit.p part.Parent = workspace end)
It is also good practice to use more descriptive variable names.