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

cannot find invalid argument #3 (CFrame expected, got function) cframe error, how do i fix?

i have a problem with my cframe.lookat and it keeps saying 'invalid argument #3 (CFrame expected, got function)' and i cannot see the error anywhere on google and other sites also I'm a bit new to scripting too so I don't really know how to fix this problem and I've tried adding some things to the script but it pops up with different errors and heres the script I'm stuck with

local ball = script.Parent

game.Players.PlayerAdded:Connect(function(Player)
	

	while wait(0.01) do
			ball.CFrame = CFrame.lookAt Vector3.new(Player.Character.Torso.Position)
	end
end)

also I'm just doing this for testing my scripting but I do need help though

1 answer

easy solution, here ya go

local ball = script.Parent
	 
game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character or plr.CharacterAdded:wait()
	
	while true do
		ball.CFrame = CFrame.lookAt(ball.Position, char.Torso.Position)
		wait(0.01)
	end
end)

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