Part Just change the position to the place of appearance in the new

Hello
I don’t know why, but for some reason, the part simply changes its position in the place in order to appear on the new

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local positionmouse = Mouse.Hit
local Selected = Instance.new("SelectionBox")
local Brick = Instance.new("Part")
local Number = game.ReplicatedStorage.numberBrcik.Value
function BrickPosition()
	if Mouse.Target.Name == "BuildPlace" then
	Brick.Size = Vector3.new(4,4,4)
Brick.Parent = game.Workspace.Teleport
Brick.Anchored = true
Brick.BrickColor = BrickColor.new("Bright red")
Brick.Position = Vector3.new(Mouse.Target.Position.X,Mouse.Target.Position.Y+2.5,Mouse.Target.Position.Z)
Brick.Name = ("Brickpart Number"..Number.."")
end
end
Mouse.Move:Connect(function()
if Mouse.Target.Name == "BuildPlace" then
		Selected.Adornee = Mouse.Target
		Selected.Parent = game.Workspace
        Selected.Color3 = Color3.fromRGB(85,0,255)
        Selected.SurfaceColor3 = Color3.fromRGB(255,0,0)
        Selected.SurfaceTransparency = 0.5
end
end) 

Mouse.Button1Down:Connect(function()
if Mouse.Target.Name == "BuildPlace" then
	Brick.Size = Vector3.new(4,4,4)
Brick.Parent = workspace
Brick.Anchored = true
Brick.BrickColor = BrickColor.Random()
Brick.Position = Vector3.new(Mouse.Target.Position.X,Mouse.Target.Position.Y+2.5,Mouse.Target.Position.Z)
Brick.Name = ("wf"..Number.."s")
	end
end)
--	local w = Instance.new("Part")
--	w.Anchored = true
--	w.Parent = game.Workspace
--	w.Position = Vector3.new(Mouse.Hit.Position.X ,Mouse.Hit.Position.Y, Mouse.Hit.Position.Z)
--Selected.Adornee = Mouse.Target
--Selected.Color3 = Color3.fromRGB(85,0,255)
--Selected.SurfaceColor3 = Color3.fromRGB(255,0,0)
--Selected.SurfaceTransparency = 0.5

I did everything right Dont have error

1 Like

You’re only creating a new part once, instead you should create it every time you want to place a new one down. Also a quick thing to remember is you should set the parent last, after you’ve initialized the object.

Mouse.Button1Down:Connect(function()
	if Mouse.Target.Name == "BuildPlace" then
		local Brick = Instance.new("Part")
		-- set brick properties
		Brick.Parent = game.Workspace.Teleport
	end
end)
2 Likes

Thanks, I can’t check right now. I’m not at home.
I checked and it works. Thanks.