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

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

Asked by 6 years ago

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
0
if you are storing objects, use server storage or replicated storage saSlol2436 716 — 6y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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

0
Thank you for the answer! It helped me understand how to use vector3 overall and how to implement it in my script! BunnyFilms1 297 — 6y
Ad

Answer this question