So I wanna rotate a part of a model to face the position of another part. I have tried the following script, but it always return the error Argument 1 missing or nil..

How would I go about fixing this?

Here's the line of code I have that's suposed to rotate it:

script.Parent.Top:SetPrimaryPartCFrame(script.Parent.Top.PrimaryPart.Position, game.Workspace:FindFirstChild(Target).HumanoidRootPart.Position)

Note: "game.Workspace:FindFirstChild(Target).HumanoidRootPart.Position" is the position the model is supposed to look at.

Any help is appreciated!

Thanks!

3 comments

0

Target is nil

0

Look at the wiki here: https://developer.roblox.com/en-us/api-reference/datatype/CFrame#functions What you want is the 2nd CFrame.new(), or CFrame.fromMatrix

0

The wiki explains nothing good about how to use that CFrame.fromMatrix bruh