Hey! So I'm trying to make this script where when the player clicks anywhere a part will spawn where ever the mouse was clicked, the problem is that the part spawns but not at the position of the mouse. Here's the code:
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local PosX,PosY,PosZ = Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z
Mouse.Button1Down:connect(function()
local MousePos = Mouse.Hit.p
if Mouse.Target ~= nil then
local Part = Instance.new("Part", game.Workspace)
Part.Position = Vector3.new(PosX,PosY,PosZ)
end
end)
I'm completely new to mouse manipulation and i'm trying to get better at it, if someone could leave an explanation on why this is happening that would be great!
