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

Argument 3 missing or nil whever i try to lerp angles?

So I made this script that whenever the game runs it will make the part face another part using linear interpolation (CFrame:Lerp()), but whenever I put the 2nd part's CFrame.p inside the CFrame.angles() it says "Argument 3 missing or nil", here is the script I'm using:


Part1 = game.Workspace.Part
Part2 = game.Workspace.Part2
d = nil

while true do
	wait()
	print(Part2.CFrame.Position)
	   Part1.CFrame = Part1.CFrame:Lerp(Part1.CFrame * CFrame.Angles(game.Workspace.Part2.Position), 0.01) --The error is here.
	print(Part1.CFrame.p)
end

The output reads:

  33.4099998, 11.6699696, -83.8799973
  14:27:19.557 - Argument 3 missing or nil
14:27:19.557 - Stack Begin
14:27:19.558 - Script 'ServerScriptService.Script', Line 10
14:27:19.558 - Stack End

Is it a newbie mistake, because i put a wrong value or something else? thank you!

EDIT: What I did to fix this was do Part1.CFrame = Part1.CFrame:Lerp(CFrame.new(Part1.CFrame.p, Part2.CFrame.p), 0.01) instead of Part1.CFrame = Part1.CFrame:Lerp(Part1.CFrame * CFrame.Angles(game.Workspace.Part2.Position), 0.01)

1 comment

0

Do game.Workspace.Part2.Orientation instead of game.Workspace.Part2.Position.

2 answers

✓ Accepted answer

CFrame.Angles() needs three parameters you only gave it one

see CFrame API wiki

I think the other person that awnsered is right with what u ment to do, but he didnt explain it

i dont know

Part1 = game.Workspace.Part
Part2 = game.Workspace.Part2
d = nil

while true do
    wait()
    print(Part2.CFrame.Position)
       Part1.CFrame = Part1.CFrame:Lerp(game.Workspace.Part2.CFrame, 0.01) --The error is here.
    print(Part1.CFrame.p)
end

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