Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this part not spawning where I click?

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()

  

Mouse.Button1Down:Connect(function()

local part = Instance.new("Part")

part.Parent = workspace

part.Position = Vector3.new(Mouse.Hit.Position)

print(Mouse.Hit.Position)

end)

Don't know if it is just me being tired or stupid. What happens is the part spawns in the middle of the baseplate and not where I click.

1 answer

Hello, Thesquid13; I have fixed your LOCALSCRIPT, it works fine now, the problem was the way you were trying to get the MOUSE's position and combine it with Vector3, i have also changed the line where you were trying to set the part's position, so instead, its CFrame, why? you ask? its because using POSITION will place the part over anything that is blocking the part to be placed at the exact location of mouse, so you should use CFrame in situations such as this, by the way, all you had to do is to define XYZ of the MOUSE'S POSITION, and i did that for you :

local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.Button1Down:Connect(function() local part = Instance.new("Part") part.Parent = game.Workspace part.CFrame = CFrame.new(Mouse.Hit.Position.X, Mouse.Hit.Position.Y, Mouse.Hit.Position.Z) print(Mouse.Hit.Position) end)

Have fun!

This discussion is preserved as it was. New answers, comments, and votes are closed.