Why is this part floating in air

the topic is tells u whats wrong, my building system broke or is it like that?
Capture

Ok so its floating in air
I kept my cursor to baseplate top, but its in air

The script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = Instance.new("Part",workspace)
local selection = Instance.new("SelectionBox",part)
selection.Adornee = part
selection.Color3 = Color3.new(0.333333, 0.666667, 0)
part.Transparency = 0.5

mouse.Move:Connect(function()
    local newframe = mouse.Hit
    part.CFrame = newframe
    part.Anchored = true
    part.Material = Enum.Material.SmoothPlastic
    part.BrickColor = BrickColor.new("Bright green")
    part.CanCollide = false
    part.Name = "PlacingBlock"
    while wait() do
        part.Position.Y = 0.5
    end
end)

mouse.Button1Down:Connect(function()
    local part2 = Instance.new("Part",workspace)
    part2.CFrame = game.Workspace:FindFirstChild("PlacingBlock").CFrame
    part2.Anchored = true
    part.CanCollide = true
    part.Material = Enum.Material.SmoothPlastic
    part.BrickColor = BrickColor.new("White")
end)
1 Like

What’s this loop for? also it’s a never ending loop.

2 Likes

So it stays on baseplate top position not in air, but its still in air

1 Like

I see what you want to do. Can you replace this loop

With this:

part.Position.Y = 0.5
2 Likes

Oh thank you and why is the part in some random orientation, how can i fix it to?

1 Like

umm this don’t work
222

1 Like
part.Position = Vector3.new(0, 0.5, 0); -- Vector3.new(x, y, z)

You need to use Vector3 in order to modify the Position property.

1 Like

But the x and z position will be 0. It should be where the player keeps the cursor

1 Like
part.Position = Vector3.new(part.Position.X, .5, part.Position.Z)
2 Likes

True, I only gave a quick example though.

Thx it worked! But the only thing which is not working now is its orientation is random

This script should work (the orientation will be fixed):

mouse.Move:Connect(function()

    local newframe = mouse.Hit

    part.CFrame = CFrame.new(newframe.X, 0.5, newframe.Z)

    part.Orientation = Vector3.new(0,0,0)

    part.Anchored = true

    part.Material = Enum.Material.SmoothPlastic

    part.BrickColor = BrickColor.new("Bright green")

    part.CanCollide = false

    part.Name = "PlacingBlock"

end)
1 Like

Oh it works thank you.Building system works better

1 Like