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

How do I CFrame this from it's current position?

Asked by
Avectus 120
9 years ago

I'm trying to make a shield move from it's base. The script works fine as it is but I'm planning of having a lot of these 'shields' around the map and instead of going through each one putting in their position, I'm wondering if there's a way to CFrame a brick from it's current position, so no matter where I put it the shield part will move up 3.

local HoloShield = script.Parent.HoloShield

for i = 0, 3, 0.1 do
    HoloShield.CFrame = CFrame.new(-64.5, 1+i, -121.5)
    wait()
end

Thanks.

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

What You Need To Do

You need to CFrame the shield relative to it's current CFrame, and multiply it by an offset.

Code

local HoloShield = script.Parent.HoloShield
local offset = CFrame.new(0,3,0)
local incr = .1

for i = 0, 3, 0.1 do
    local increment = offset * CFrame.new(incr,incr,incr) --Make it into increments
    HoloShield.CFrame = HoloShield.CFrame * increment --Offset by the increment
    wait()
end
Ad

Answer this question