Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Putting a block at the end of another block?

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

2 comments

0

I'm confused. Isn't zpos.CFrame already what you are asking for?

0

It's making it a weird thing, it's taking diffrent axis's or somethin

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.