Title really says it all
-- Function to return the position and lookVector
function ReturnCFrameValues()
local WorldSpace = centre.CFrame:ToWorldSpace(TableToCFrame(position))
return WorldSpace.Position, WorldSpace - WorldSpace.Position
end
local position, lookAt = ReturnCFrameValues()
block:SetPrimaryPartCFrame(
CFrame.new(
position,
lookAt
)
)
I get this error invalid argument #2 to ‘new’ (Vector3 expected, got CFrame)
I may be confused about this, but you can just add the lookvector to the CFrame, like this:
local newCFrame = oldCFrame + oldCFrame.LookVector
Ok I think I see your actual problem. You are performing arithmetic with a CFrame and a Vector3, which outputs a CFrame. That’s why you’re getting that error. lookAt needs to be a Vector3 to work, but you are returning a CFrame. A simple way to get around this is by just converting them all to a Vector3 before you return them:
local a = WorldSpace - WorldSpace.Position
return WorldSpace.Position, Vector3.new(a.X, a.Y, a.Z)
1 Like