game:GetService("RunService").RenderStepped:connect(function()
if Player:GetAttribute("Buildmode") == true then
local mouseRay = mouse.UnitRay
local rayCastParams = RaycastParams.new()
rayCastParams.FilterDescendantsInstances = {block,Player.Character}
rayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = game.Workspace:Raycast(mouseRay.Origin,mouseRay.Direction.unit * 500,rayCastParams)
if raycastResult then
local target = raycastResult.Instance:GetFullName()
local pos = raycastResult.Position
local norm = raycastResult.Normal
local block = game.Workspace.Ignore:WaitForChild("SelectBox")
local endPos = (pos + (norm * (block.Size*.5)))
local endPos = Vector3.new(math.floor(endPos.X + 0.5) + block.Size.X % 2 / 2 , math.round(endPos.Y), math.floor(endPos.Z + 0.5) + block.Size.Z % 2 / 2)
block.CFrame = CFrame.new(endPos)
if game.Workspace.Ignore:WaitForChild("SelectBox"):FindFirstChildWhichIsA("Model") then
game.Workspace.Ignore:WaitForChild("SelectBox"):FindFirstChildWhichIsA("Model").PrimaryPart.CFrame = CFrame.new(endPos)
end
end
end
end)
This script sets the part’s position with CFrame when renderstepped happens, but for some reason the orientation can never be changed when the script is running.