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

How to add +X or +Y to brick axis?

Hello! So I have a tool and when you click while it being equipped, the part gets cloned to where to clicked. How can I do +Y on it's axis so it does not clone partially in the ground?

local function createPart(location)
	local part = game.Lighting.Coin:Clone()
	part.CFrame = location
	part.Parent = workspace
end

1 comment

0

if you are storing objects, use server storage or replicated storage

1 answer

✓ Accepted answer

If you wanted to add a number you could do this

Position+Vector3.new(0,3--[[adding 3 to y]],0)

But we can add a vector3 to a cframe

CFrame+Vector3.new(0,3,0)

You can also do other mathematical functions like multiple, subtract, and divide

CFrame*CFrame.new(0,3,0)

--you can multiple all axis by doing this
Position*3
--all axis will be multiplied by 3

So in your case to make the part's position with CFrame go up we can do this

local function createPart(location)
    local part = game.Lighting.Coin:Clone()
    part.CFrame = location+Vector3.new(0,3,0)
    part.Parent = workspace
end

More info

1 comment

0

Thank you for the answer! It helped me understand how to use vector3 overall and how to implement it in my script!

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