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

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

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

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

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