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

Whats the issue in the second code? (Basic CFrames)

There are two variations of the code i can use, but the second one makes the blue block aim in the right direction, but far off. Can someone explain whats happening? Im Just starting to learn CFrames, so i have no clue.

First scenario: https://imgur.com/a/3ZcGrwH

local Subject = script.Parent.Subject
local Target = script.Parent.Target

local i = 5
while wait() do
	i = i + 1
	print(i)

	local ATP = Vector3.new(90, i, 10)
	Subject.CFrame = CFrame.new(ATP,Target.Position)
	if i > 80 then
		i = 5
	end  

end

Second Scenario: https://imgur.com/a/aFqqpnp

local Subject = script.Parent.Subject

local Target = script.Parent.Target


local i = 5
while wait() do
	i = i + 1
	print(i)
	
	local ATP = Vector3.new(90, 5, 10)
	
	Subject.CFrame = CFrame.new(ATP,Target.Position) + Vector3.new(0, i, 0)
	
	if i > 80 then
		i = 5
	end
end

1 comment

1

Can you shut up?

1 answer

The second one should be subtracting the new vector3, not adding it.

3 comments

0

ok let me try that

0

Instead it just goes down, what im trying to do is have it in the second scripts format, while having the rotation work correctly

0

I'm not sure why you want to do it like that, but another thing you can do is replace line 11 with this: local ATP = Vector3.new(90, 0, 10)

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