Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Putting a block at the end of another block?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

Alright so I'm trying to get a block to place at the end of a block, Visual: http://prntscr.com/89p4yf

So as you can see in the ms.Paint visual, I need the block at the very end of the brick, here is what I have so far:

Another problem I can see happening is that on some bricks, the Z axis for size doesn't always mean it's in the Z axis for position, if that makes any sense.

--Determines where the block will be place VVV
function determinexyzscales(partname)
    local mainspot = game.Workspace.Map.Walls[partname].SpotBrick
    mainspot.Size = Vector3.new(1,1,1)
    mainspot.CFrame = mainspot.Parent.CFrame
    local xsize = mainspot.Parent.Size.X
    local z = mainspot.Parent.Position.Z
    local zsiz = mainspot.Parent.Size.Z
    z = z + zsiz
    local zpos = mainspot:Clone() 
    zpos.Parent = mainspot.Parent
    zpos.Name = "ZPOSBRICK"
    zpos.CFrame = partname.CFrame * CFrame.new(0, 0, partname.Size.Z / 2)
    print("moved"..partname)
end

wait()
--Makes the brick VVVV
for i, v in pairs (walls) do
    local SpotBrick = Instance.new("Part")
    SpotBrick.Anchored = true
    SpotBrick.Parent = v
    SpotBrick.Name = "SpotBrick"
    SpotBrick.Transparency = .5
    determinexyzscales(v.Name)
end
0
I'm confused. Isn't `zpos.CFrame` already what you are asking for? BlueTaslem 18071 — 9y
0
It's making it a weird thing, it's taking diffrent axis's or somethin NotSoNorm 777 — 9y

1 answer

Log in to vote
0
Answered by
Hexcede 52
9 years ago

Pretty simple if you know about CFraming! If you want a brick in front of the brick use this:

function move(brick, brick2) -- brick2 goes in front of brick.
    brick2.CFrame = brick.CFrame * CFrame.new(brick.Size.x/2+brick2.Size.x/2, 0, 0)
end

That will move the brick (in roblox terms atleast) in front of the other brick. e.g. ~~~~~~~~~~~~~~~~~ move(workspace.Baseplate, workspace.Part) -- move the part in front of the baseplate. ~~~~~~~~~~~~~~~~~

Ad

Answer this question