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

What's wrong with my CFrame manipulation?

I'm making an unique crate unboxing system where crates will fall from the sky like an airdrop. I'm currently stuck at tweening the camera to focus at the key hole that's on the crate.

local tweenAnim = tweenService:Create(crateMain, tweenInfo, {Position = CFrame.new(Vector3.new(keyHole.Position.X + (keyHole.Size.X * 1.5), keyHole.Position.Y + (keyHole.CFrame.UpVector * 4), keyHole.Position.Z), Vector3.new(keyHole.Position.X, keyHole.Position.Y, keyHole.Position.Z))})

Here's the error.

20:52:38.751 - ReplicatedStorage.CrateSystem:312: bad argument #1 to '?' (Vector3 expected, got number) 20:52:38.752 - Stack Begin 20:52:38.752 - Script 'ReplicatedStorage.CrateSystem', Line 312 20:52:38.752 - Stack End

I'm pretty sure that only the CFrame part errors.

CFrame.new(Vector3.new(keyHole.Position.X + (keyHole.Size.X * 1.5), keyHole.Position.Y + (keyHole.CFrame.UpVector * 4), keyHole.Position.Z), Vector3.new(keyHole.Position.X, keyHole.Position.Y, keyHole.Position.Z))

Any idea on how to fix it? Thanks.

6 comments

0

It only has 2 arguments, the coordinated to tween to and the coordinate to point at

0

I double checked the blankets, nothing is wrong with them

0

Both of the arguments are Vector3 coordinates

0

keyHole.Position.Y + (keyHole.CFrame.UpVector * 4) is where the error is.

0

how am I suppose to read that ;-;

0

Remove the Vector3.new because the CFrame already checks for the position

1 answer

✓ Accepted answer
local tweenAnim = tweenService:Create(crateMain, tweenInfo, {CFrame = CFrame.new(keyHole.Position.X + (keyHole.Size.X * 1.5), keyHole.Position.Y + (keyHole.CFrame.UpVector * 4), (keyHole.Position.Z), (keyHole.Position.X), (keyHole.Position.Y), (keyHole.Position.Z)

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