I’m working on a spell/magic tool that you can activate then it does some cool stuff creating blocks.
https://gyazo.com/48f7b6a675995d9db3fc57c2439ee731
I’m using the following code to create blocks in the direction the HumanoidRootPart is oriented.
local HumanoidRootPart = Character.HumanoidRootPart
for i=1, 15 do
CreateNewBlock((HumanoidRootPart.CFrame * CFrame.new(7, 0, (-8 * i))).p)
CreateNewBlock((HumanoidRootPart.CFrame * CFrame.new(-7, 0, (-8 * i))).p)
end
CreateNewBlock is a function which has a parameter for the target position, the CreateNewBlock function does the block instancing, material, etc.
The -8 * i is used to offset blocks from each other and -7 and 7 are used so both lines of blocks are offset from each other.
Now as you may see in the gif I linked above, the HumanoidRootPart was not only oriented on the Y axis, but also on the X and Z axis. This is a problem because you can see the line of blocks eventually going into the ground.
My question is, how do I ignore certain axis using my code and make the line of blocks go straight?